home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / utilities / shell / zshell24.lha / ZShell24 / ZShell.S < prev    next >
Encoding:
Text File  |  1995-02-27  |  214.7 KB  |  11,053 lines

  1.  
  2. ****************************************************
  3. *********  ZSHELL (C) 1990,91 Paul Hayter  *********
  4. ********  updated to V2.3 by Martin Gierich ********
  5. ********    First major change: 08.06.93    ********
  6. *********    Last change: 26.02.95       *********
  7. ****************************************************
  8.  
  9. **ZShell V2.4.1, Changes since V2.3:
  10. *Bugfix: "run -c","delete device",Prompt-Farbe,"Assign" unter OS1.3
  11. *Setzt Wildstar-Flag
  12. *AppWindow/AppIcon zur File/Dirnameneingabe
  13. *MEMCLK,BORDER benutzt richtiges Fenster, nicht aktuelles
  14. *>m erhaelt review-buffer
  15. *Fehlerausgabe immer auf Konsole
  16. *Debug-Flag fuer Scripts und Aliases
  17. *ASK,MORE: Input von stdin statt inhandle
  18. *SHOW TASK zeigt bgCLI/CLI und Redir
  19. *Erroroutput during starting
  20. *noraw input abbruch
  21. *COPY: dots als Progressindicator
  22. *Eingabe von Sonderzeichen
  23. *Zeigt LowMem-Changes und Lock-Changes
  24. *Result2 zeigt richtiger Wert
  25. *List-Sort gibt auch bei Break Speicher frei
  26. *Welcome-Text
  27. *cli_CommandName/File
  28. *Hide-Flag
  29. *DIE killt Handler und Tasks
  30.  
  31. ;DEBUG    = 1
  32.  
  33. ***        TABSIZE = 8 Chars         ***
  34. ***     Local Labels named .A to .Z         ***
  35.  
  36. VERSION            equ    $1234
  37.  
  38. FLcheck        =0
  39. FLmatch        =1
  40. FLappicon    =2
  41. FLwild        =3
  42. FLerrors    =4
  43. FLdebug        =5
  44. FLcutline    =6
  45. FLall        =7
  46. FLhide        =8
  47. MaxFlags     =9
  48.  
  49. FIB            equ    260        ;FileInfoBlock
  50. ACCESS_READ        equ    -2
  51. ACCESS_WRITE        equ    -1
  52. MODE_READWRITE        equ    1004
  53. MODE_OLDFILE        equ    1005
  54. MODE_NEWFILE        equ    1006
  55.  
  56. SIGBREAKB_CTRL_C    equ    $C
  57. SIGBREAKB_CTRL_D    equ    $D
  58. SIGBREAKB_CTRL_E    equ    $E
  59. SIGBREAKB_CTRL_F    equ    $F
  60.  
  61. eb_CoolCapture    equ    46
  62. eb_ColdCapture    equ    42
  63. eb_WarmCapture    equ    50
  64. eb_KickMemPtr    equ    546
  65. eb_KickTagPtr    equ    550
  66. eb_KickCheckSum    equ    554
  67.     
  68. * FILE INFO BLOCK
  69. fib_DiskKey        equ  $0000
  70. fib_DirEntryType    equ  $0004
  71. fib_FileName        equ  $0008
  72. fib_Protection        equ  $0074
  73. fib_EntryType        equ  $0078
  74. fib_Size        equ  $007c
  75. fib_NumBlocks        equ  $0080
  76. fib_Date        equ  $0084
  77. fib_Comment        equ  $0090
  78. fib_Reserved        equ  $00e0
  79.  
  80. * INFO DATA STRUCTURE
  81. id_NumSoftErrors    equ    0
  82. id_UnitNumber        equ    4
  83. id_DiskState        equ    8
  84. id_NumBlocks        equ    12
  85. id_NumBlocksUsed    equ    16
  86. id_BytesPerBlock    equ    20
  87. id_DiskType        equ    24
  88. id_VolumeNode        equ    28
  89. id_InUse        equ    32
  90.  
  91. * TASK
  92. tc_State        equ    15
  93. tc_SigWait        equ    22
  94.  
  95. * PROCESS
  96.  
  97. pr_MsgPort        equ    92
  98. pr_SegList        equ    128
  99. pr_StackSize        equ    132
  100. pr_GlobVec        equ    136
  101. pr_TaskNum        equ    140
  102. pr_StackBase        equ    144
  103. pr_Result2        equ    148
  104. pr_CurrentDir        equ    152
  105. pr_CIS            equ    156
  106. pr_COS            equ    160
  107. pr_ConsoleTask        equ    164
  108. pr_FileSystemTask    equ    168
  109. pr_CLI            equ    172
  110. pr_ReturnAddr        equ    176
  111. pr_PktWait        equ    180
  112. pr_WindowPtr        equ    184
  113. pr_HomeDir        equ    188    KS2
  114. pr_Flags        equ    192
  115. pr_CES            equ    224
  116.  
  117. * COMMAND LINE INTERFACE
  118. cli_Result        equ    0
  119. cli_SetName        equ    4
  120. cli_CommandDir        equ    8
  121. cli_ReturnCode        equ    12
  122. cli_CommandName        equ    16
  123. cli_FailLevel        equ    20
  124. cli_Prompt        equ    24
  125. cli_StandardInput    equ    28
  126. cli_CurrentInput    equ    32
  127. cli_CommandFile        equ    36
  128. cli_Interactive        equ    40
  129. cli_Background        equ    44
  130. cli_CurrentOutput    equ    48
  131. cli_DefaultStack    equ    52
  132. cli_StandardOutput    equ    56
  133. cli_Module        equ    60
  134.  
  135. * FILE HANDLE
  136. fh_Link            equ    0
  137. fh_Port            equ    4
  138. fh_Type            equ    8
  139. fh_Buf            equ    12
  140. fh_Pos            equ    16
  141. fh_End            equ    20
  142.  
  143. * FILE LOCK
  144. fl_Link            equ    0
  145. fl_Key            equ    4
  146. fl_Access        equ    8
  147. fl_Task            equ    12
  148. fl_Volume        equ    16
  149.  
  150. * DATESTAMP
  151. ds_Days            equ    0
  152. ds_Minute        equ    4
  153. ds_Tick            equ    8
  154.  
  155. RETURN_OK        EQU  0
  156. RETURN_WARN        EQU  5
  157. RETURN_ERROR        EQU  10
  158. RETURN_BAD        EQU  15
  159. RETURN_FAIL        EQU  20
  160.  
  161. *Assign Stuff
  162. dl_Root        equ    34    APTR
  163. rn_Info        equ    24    BPTR
  164. rn_Flags    equ    52    LONG
  165. di_DevInfo    equ    4    BPTR
  166. di_NetHand    equ    16    BPTR
  167. dvi_Next    equ    0    BPTR
  168. dvi_Type    equ    4    LONG
  169. dvi_Task    equ    8    APTR
  170. dvi_Lock    equ    12    BPTR
  171. dvi_Handler    equ    16    (PathPtr)
  172. dvi_StackSize    equ    20
  173. dvi_LockList    equ    20
  174. dvi_Priority    equ    24
  175. dvi_Startup    equ    28
  176. dvi_SegList    equ    32
  177. dvi_GlobVec    equ    36
  178. dvi_Name    equ    40    BSTR
  179. dlt_device    equ    0    <-- contents of dvi_Type
  180. dlt_directory    equ    1
  181. dlt_volume    equ    2
  182. dlt_late    equ    3
  183. dlt_nonbind    equ    4
  184.  
  185. *Resident Stuff
  186. resi_link    equ    0    ;BPTR
  187. resi_usecount    equ    4    ;LONG
  188. resi_seglist    equ    8    ;BPTR
  189. resi_name    equ    12    ;BSTR
  190. resi_length    equ    4+4+4
  191.  
  192. *Icon Lib Stuff
  193. sm_Process    equ    $14
  194. sm_Segment    equ    $18
  195. sm_NumArgs    equ    $1c
  196. sm_ToolWindow    equ    $20
  197. sm_ArgList    equ    $24
  198. wa_Lock        equ    0
  199. wa_Name        equ    4
  200. do_Magic    equ    0    ;must be $e310
  201. do_Type        equ    $30
  202. do_ToolTypes    equ    $36
  203. do_ToolWindow    equ    $46
  204. do_StackSize    equ    $4a
  205.  
  206. *WAppMessage
  207. am_Type        equ    20
  208. am_NumArgs    equ    30
  209. am_ArgList    equ    34
  210.  
  211. * AVAIL STUFF
  212. MEMF_PUBLIC        equ 1
  213. MEMF_CHIP        equ 2
  214. MEMF_FAST        equ 4
  215. MEMF_CLEAR        equ $10000
  216. MEMF_LARGEST        equ $20000
  217.  
  218. * ACTIONS
  219. ACTION_SCREEN_MODE    EQU    994
  220. ACTION_INHIBIT        EQU    31
  221. ACTION_MORE_CACHE    EQU    18
  222. ACTION_RENAME_DISK    EQU    9
  223. ACTION_DIE        EQU    5
  224. ACTION_DISK_CHANGE    EQU    33
  225. ACTION_SET_DATE        EQU    34
  226. ACTION_DISK_INFO    EQU    25
  227. ACTION_WRITE_PROTECT    EQU    1023
  228. ACTION_FLUSH        EQU    27
  229. ACTION_READ        EQU    "R"
  230. ACTION_WRITE        EQU    "W"
  231.  
  232. dp_Link        EQU  $00   ;DosPacket Structure
  233. dp_Port        EQU  $04
  234. dp_Type        EQU  $08
  235. dp_Arg1        EQU  $14
  236. dp_SIZEOF    EQU  $30
  237.  
  238. sp_Msg        EQU  $00   ;StandardPacket Structure
  239. sp_Pkt        EQU  $14
  240. sp_SIZEOF    EQU  $44
  241.  
  242. LH_HEAD        equ    0
  243. LH_TAIL        equ    4
  244. LH_TAILPRED    equ    8
  245. LH_TYPE        equ    12
  246. LH_PAD        equ    13
  247. LH_SIZE        equ    14
  248.  
  249. LN_SUCC        equ    0
  250. LN_PRED        equ    4
  251. LN_TYPE        equ    8
  252. LN_PRI        equ    9
  253. LN_NAME        equ    10
  254. LN_SIZE        equ    14
  255.  
  256. NT_MSGPORT    EQU  4
  257.  
  258. MP_FLAGS    EQU  $0E   ;Message Port Structure
  259. MP_SIGBIT    EQU  $0F   ;Signal bit number
  260. MP_SIGTASK    EQU  $10   ;Task to be signalled
  261. MP_MSGLIST    EQU  $14   ;Message linked list
  262. MP_SIZE        EQU  $22
  263.  
  264. mn_ReplyPort    equ    14
  265. mn_Length    equ    18
  266. mn_Size        equ    20
  267.  
  268. PA_SIGNAL    EQU  0       ;PutAction messages
  269.  
  270.     
  271. * LIBRARY CALLS
  272. * EXEC
  273. _LVOOpenLibrary        equ    -552
  274. _LVOOldOpenLibrary    equ    -408
  275. _LVOCloseLibrary    equ    -414
  276. _LVOSetFunction        equ    -420
  277. _LVOAllocMem        equ    -198
  278. _LVOFreeMem        equ    -210
  279. _LVORawDoFmt        equ    -522
  280. _LVORawMayGetChar    equ    -510
  281. _LVOFindTask        equ    -294
  282. _LVOSetTaskPri        equ    -300
  283. _LVOAddTask        equ    -282
  284. _LVORemTask        equ    -288
  285. _LVOForbid        equ    -132
  286. _LVOPermit        equ    -138
  287. _LVOAvailMem        equ    -216
  288. _LVOAddPort        equ    -354
  289. _LVORemPort        equ    -360
  290. _LVOFindPort        equ    -390
  291. _LVOPutMsg        equ    -366
  292. _LVOGetMsg        equ    -372
  293. _LVOReplyMsg        equ    -378
  294. _LVOWaitPort        equ    -384
  295. _LVOWait        equ    -318
  296. _LVOSignal        equ    -324
  297. _LVOSetSignal        equ    -306
  298. _LVOAllocSignal        equ    -330
  299. _LVOFreeSignal        equ    -336
  300. _LVOOpenDev        equ    -444
  301. _LVOCloseDev        equ    -450
  302. _LVODoIO        equ    -456
  303. _LVOCreateMsgPort    equ    -666    KS 2.0+
  304. _LVODeleteMsgPort    equ    -672
  305.  
  306. * DOS
  307. _LVOSetProtection    equ    -186
  308. _LVOOutput        equ    -60
  309. _LVOWrite        equ    -48
  310. _LVOLock        equ    -84
  311. _LVOUnLock        equ    -90
  312. _LVODupLock        equ    -96
  313. _LVOExamine        equ    -102
  314. _LVOExNext        equ    -108
  315. _LVOOpen        equ    -30
  316. _LVOClose        equ    -36
  317. _LVORead        equ    -42
  318. _LVOInput        equ    -54
  319. _LVODeleteFile        equ    -72
  320. _LVORename        equ    -78
  321. _LVOCreateDir        equ    -120
  322. _LVOCurrentDir        equ    -126
  323. _LVOIoErr        equ    -132
  324. _LVOParentDir        equ    -210
  325. _LVOLoadSeg        equ    -150
  326. _LVOUnLoadSeg        equ    -156
  327. _LVOCreateProc        equ    -138
  328. _LVOInfo        equ    -114
  329. _LVODateStamp        equ    -192
  330. _LVOSeek        equ    -66
  331. _LVODeviceProc        equ    -174
  332. _LVODelay        equ    -198
  333. _LVOSetComment        equ    -180
  334. _LVOIsInteractive    equ    -216
  335. _LVOReadLink        equ    -438    KS 2.0+
  336. _LVOMakeLink        equ    -444
  337. _LVOFault        equ    -468
  338. _LVOPrintFault        equ    -474
  339. _LVOAssignLock        equ    -612
  340. _LVOAssignLate        equ    -618
  341. _LVOAssignPath        equ    -624
  342. _LVOAssignAdd        equ    -630
  343. _LVORemAssignList    equ    -636
  344. _LVOFormat        equ    -714
  345. _LVOAddBuffers        equ    -732
  346. _LVOFilePart        equ    -870
  347. _LVOPathPart        equ    -876
  348. _LVOInhibit        equ    -726
  349. _LVOParsePatternNC    equ    -966
  350. _LVOMatchPatternNC    equ    -972
  351. _LVONameFromLock    equ    -402
  352.  
  353. *Intuition
  354. _LVOPrintIText        equ    -216
  355. _LVODisplayAlert    equ    -90
  356. _LVODisplayBeep        equ    -96
  357. _LVOLockIBase        equ    -414
  358. _LVOUnlockIBase        equ    -420
  359. _LVORefreshWindowFrame    equ    -456
  360. _LVOSizeWindow        equ    -288
  361. _LVOMoveWindow        equ    -168
  362. _LVOActivateWindow    equ    -450
  363. _LVORemakeDisplay    equ    -384
  364. _LVOMakeScreen        equ    -378
  365. _LVORethinkDisplay    equ    -390
  366.  
  367. *Icon
  368. _LVOGetDiskObject    equ    -78
  369. _LVOGetDefDiskObject    equ    -120
  370. _LVOPutDiskObject    equ    -84
  371. _LVOFreeDiskObject    equ    -90
  372. _LVOFindToolType    equ    -96
  373. _LVOMatchToolValue    equ    -102
  374.  
  375. *Workbench
  376. _LVOAddAppIconA        equ    -60
  377. _LVOAddAppWindowA    equ    -48
  378. _LVORemoveAppIcon    equ    -66
  379. _LVORemoveAppWindow    equ    -54
  380. _LVOWBInfo        equ    -90
  381.  
  382.  
  383. * DOS LIBRARY
  384. dl_A2            equ    42
  385.  
  386. *SYSTEM0 stuff!!!!!!!!!!
  387. REG_SysBase    equr a6
  388.  
  389. callsys    macro
  390.     jsr _LVO\1(REG_SysBase)
  391.     endm
  392.  
  393. * parameter offsets & stack
  394. ;SAVED_REGS    reg    a2-a6/d2-d3
  395. DELTA        equ    7*4
  396. ARG_NAME    equ    4+DELTA
  397. ARG_SEGLIST    equ    8+DELTA
  398. ARG_ARGS    equ    12+DELTA
  399.  
  400. * additional return codes
  401. NO_CLI        equ    -1
  402. NO_MEM        equ    -2
  403.  
  404. * local constants
  405. MAXBSTR        equ    255
  406. LF        equ    10
  407.  
  408. * register usage
  409. REG_Result    equr    d3
  410. REG_Process    equr    a2      ;may not be A4, see below!
  411. REG_CLI        equr    a3
  412. REG_CIS        equr    a4      ;may not be A3, see below!
  413. REG_PrevStack    equr    a1    ;V2.0 changed from a5 to a1
  414.  
  415. * local stack frame
  416. * STRUCTURE      StackFrame,0
  417.         RSRESET
  418. sf_CommandName    RS.B    MAXBSTR+1        ;BSTR, length byte!
  419. sf_CommandArgs    RS.B    MAXBSTR+1        ;not a BSTR, LF-terminated!
  420. sf_PrevStack        RS.L    1
  421. sf_SaveReturnAddr    RS.L    1
  422. sf_SaveModule        RS.L    1
  423. sf_SaveCommandName    RS.L    1
  424. sf_StackBase    RS.L    1
  425. sf_StackSize    RS.L    1
  426. sf_PushSize    RS.L    1
  427. sf_Process    RS.L    1
  428. sf_CLI        RS.L    1
  429. sf_CIS        RS.L    1
  430. sf_SCB_Buf    RS.L    1
  431. sf_SCB_Pos    RS.L    1
  432. sf_SCB_End    RS.L    1
  433. sf_Membase    RS.L    1
  434. sf_SIZEOF    RS.W    0
  435.  
  436. *Constants (only LONGS!)
  437. SHELLINE_SIZE    equ    256    V1.30
  438. CLIBUF_SIZE    equ    256
  439. NEWPRINTSIZE    equ    200
  440. HISTORY_SIZE    equ    1024    MUST BE POWER OF 2
  441.  
  442. * THE GENERAL MEMORY BLOCK (LONGS!)
  443.         RSRESET
  444. blockbase    RS.B    260    the fib or info goes here
  445. sp_node        RS.B    14    DOSpacket
  446. sp_reply    RS.L    1
  447. sp_length    RS.W    1
  448. sp_link        RS.L    1
  449. sp_port        RS.L    1
  450. packettype    RS.L    1
  451. sp_res1        RS.L    1
  452. sp_res2        RS.L    1
  453. myArg1        RS.L    1
  454. myArg2        RS.L    1
  455. myArg3        RS.L    1
  456. myArg4        RS.L    1
  457. myArg5        RS.L    1
  458. myArg6        RS.L    1
  459. myArg7        RS.L    1
  460. packettask    RS.L    1
  461. devproc        RS.L    1    endofpacket
  462. unusedlock    RS.L    1
  463. last_failcode    RS.L    1
  464. outhandle    RS.L    1
  465. inhandle    RS.L    1
  466. unusedin    RS.B    40
  467. unusedout    RS.B    40
  468. stdout        RS.L    1
  469. stdin        RS.L    1
  470. EntryA0        RS.L    1
  471. better_Seglist    RS.L    1
  472. parm1        RS.L    1    addr of each parameter within shelline
  473. parm2        RS.L    1
  474. parm3        RS.L    1
  475. parm4        RS.L    1
  476. parm5        RS.L    1
  477. parm6        RS.L    1
  478. parm7        RS.L    1
  479. parm8        RS.L    1
  480. parm9        RS.L    1
  481. parm10        RS.B    4*16    16 extra parms
  482. endofparms    RS.L    1    for NULL end
  483.  
  484. shelline    RS.B    SHELLINE_SIZE
  485. endofshelline
  486. CLIbuf        RS.B    CLIBUF_SIZE
  487. NewPrintBuffer    RS.B    NEWPRINTSIZE
  488. errorstack    RS.L    1
  489. topstack    RS.L    1
  490. stacksize    RS.L    1
  491. temp1        RS.L    1
  492. temp2        RS.L    1
  493. temp3        RS.L    1
  494. temp4        RS.L    1
  495. tempbuf        RS.B    2*SHELLINE_SIZE    double shellinesizebuffer
  496. temp2buf    RS.B    80    80 char temp buffer
  497. dosbase        RS.L    1
  498. intuibase    RS.L    1
  499. Result2        RS.L    1
  500. kickver        RS.W    1
  501. old_prompt    RS.L    1
  502. old_setname    RS.L    1
  503. old_homedir    RS.L    1
  504. Unused        RS.W    1
  505. CLIptr        RS.L    1
  506. Flags        RS.L    1
  507. prompt_cr    RS.L    1
  508. ConsoleSwitch    RS.L    1
  509. count_line    RS.L    1
  510. ignoreit    RS.B    60    for filenamecompletition
  511. OldCTask    RS.L    1
  512. OldCIS        RS.L    1
  513. OldCOS        RS.L    1
  514. bordersize    RS.L    1
  515. scsize        RS.L    1
  516. scaddr        RS.L    1
  517. scptr        RS.L    1
  518. scflag        RS.B    1
  519. openwin_flag    RS.B    1
  520. noresi_flag    RS.B    1
  521. noreview_flag    RS.B    1
  522. ReviewMem    RS.L    1
  523. ReviewPtr    RS.L    1
  524. ReviewSize    RS.L    1
  525. unused_area    RS.B    256
  526. now        RS.L    1
  527. nost        RS.L    1
  528. then        RS.L    1
  529. past        RS.B    HISTORY_SIZE    history buffer=1024 bytes
  530. thistask    RS.L    1
  531. gather_ptr    RS.L    1
  532. gather        RS.B    40    CSI string=40 bytes
  533. tempbytes    RS.W    1
  534. first_set_defn    RS.L    1
  535. MPipePtr    RS.L    1
  536. app_name    RS.L    1
  537. wbbase        RS.L    1
  538. closecdir    RS.L    1
  539. temp5        RS.L    1
  540. temp6        RS.L    1
  541. temp7        RS.L    1
  542. appwinport    RS.L    1
  543. appwindow    RS.L    1
  544. unused_str    RS.B    20    UNUSED !
  545. windowname    RS.L    1
  546. mem_addr    RS.L    1
  547. wild_flag    RS.B    1
  548. unused_flag    RS.B    1
  549. wild_string    RS.B    80    allow 80 chars for wildcard
  550. date_mark    RS.L    3    3 lwords
  551. mem_mark    RS.L    3    3 lwords chip/fast/total
  552. CD_string    RS.B    80    Allow 80 bytes.
  553. prompt_string    RS.B    80    Allow 80 bytes.
  554. prompt_args    RS.B    40    Allow 40 bytes
  555. line_count    RS.W    1
  556. mult_comm_flag    RS.W    1    
  557. next_comm_ptr    RS.L    1
  558. break_flag    RS.B    1
  559. unused_level    RS.B    3
  560. cd_block    RS.L    1
  561. cd_volnode    RS.L    1
  562. recurs_flag    RS.W    1
  563. indent_count    RS.W    1
  564. resi_flag    RS.B    1
  565. forcediskflag    RS.B    1
  566. CLIflag        RS.B    1
  567. WBflag        RS.B    1
  568. window_old    RS.L    1
  569. wb_msg        RS.L    1
  570. iconbase    RS.L    1
  571. diskobj        RS.L    1
  572. filesys_old    RS.L    1
  573. cdir_old    RS.L    1
  574. cdback        RS.L    1
  575. ctrl_codes    RS.B    16    Keyboard-CTRL-Codes
  576. if_flag        RS.B    1
  577. if_condition    RS.B    1
  578. goto_flag    RS.B    1
  579. memclk_flag    RS.B    1
  580. dest_label    RS.B    60
  581. unused_me    RS.L    1
  582. mem_offset_addr    RS.L    1
  583. io_Message    RS.B    20    io-request (timer)
  584. io_Device    RS.L    1
  585. io_Unit        RS.L    1
  586. io_Command    RS.W    1
  587. io_Flags    RS.B    1
  588. io_Error    RS.B    1
  589. tv_secs        RS.L    1
  590. tv_micro    RS.L    1
  591. io_pad        RS.L    2    ;don't remove
  592. sizeofblk    RS.W    0
  593.  
  594.  
  595.  
  596. ********************************************
  597.  
  598. ;    SECTION    MYSHELL,CODE
  599.     
  600. ;Try to open dos then do the shell
  601. start    moveq    #-1,d7
  602.     move.l    a0,a3
  603.     move.l    4.w,a6
  604.     move.l    #sizeofblk,d0
  605.     move.l    #1+1<<16,d1        "memf_public" & clear it
  606.     jsr    _LVOAllocMem(a6)    alloc general mem block
  607.     tst.l    d0
  608.     beq    blkfail
  609.     move.l    d0,a5            A5=MEMBASE
  610.     move.l    sp,topstack(a5)
  611.     move.l    a3,EntryA0(a5)
  612.     move.w    20(a6),kickver(a5)        Kickstart-Version
  613.     lea    intuiname(pc),a1
  614.     jsr    _LVOOldOpenLibrary(a6)
  615.     tst.l    d0
  616.     beq    intfail
  617.     move.l    d0,intuibase(a5)
  618.     lea    dosname(pc),a1
  619.     jsr    _LVOOldOpenLibrary(a6)
  620.     tst.l    d0
  621.     beq    dosfail
  622.     move.l    d0,dosbase(a5)
  623.     clr.w    CLIflag(a5)        delete CLI&WBflag
  624.     sub.l    a1,a1
  625.     jsr    _LVOFindTask(a6)
  626.     move.l    d0,thistask(a5)        save this task address
  627.     move.l    d0,a2
  628.     move.l    pr_CLI(a2),d0
  629.     bne.s    .A
  630.     subq.w    #1,CLIflag(a5)        WB-Start
  631.     lea    pr_MsgPort(a2),a0
  632.     IFND    DEBUG
  633.     jsr    _LVOWaitPort(a6)
  634.     ENDC
  635.     lea    pr_MsgPort(a2),a0
  636.     jsr    _LVOGetMsg(a6)
  637.     move.l    d0,wb_msg(a5)
  638.     beq.s    .C
  639.     move.l    d0,a0
  640.     clr.l    sm_Segment(a0)        Clear Seg-Descriptor
  641. .C    move.l    pr_StackSize(a2),stacksize(a5)
  642.     move.l    pr_SegList(a2),d0
  643.     beq.s    .B
  644.     lsl.l    #2,d0
  645.     move.l    d0,a0
  646.     clr.l    12(a0)            Clear SegPointer
  647.     bra.s    .B
  648. .A    lsl.l    #2,d0            CLI-Start
  649.     move.l    d0,a2
  650.     move.l    cli_DefaultStack(a2),d0
  651.     lsl.l    #2,d0
  652.     move.l    d0,stacksize(a5)    save stacksize
  653.     clr.l    cli_Module(a2)        do not free seglist
  654.     cmp.b    #"r",1(a3)
  655.     bne.s    .B
  656.     addq.b    #1,noresi_flag(a5)
  657. .B    move.l    dosbase(a5),a6        A6=DOSBASE
  658.     tst.b    noresi_flag(a5)
  659.     bne.s    doIT
  660.     lea    ZShellName(pc),a4
  661.     bsr    search_res2
  662.     lea    start-4(pc),a1
  663.     tst.l    d0
  664.     IFD    DEBUG
  665.     bra.s    doIT
  666.     ENDC
  667.     beq.s    cresi
  668.     lsl.l    #2,d0
  669.     move.l    d0,a2
  670.     nop
  671.     nop
  672. VCheck    cmp.w    #VERSION,VCheck-start+6(a2)
  673.     bne    normex
  674.     addq.l    #1,resi_usecount(a0)
  675.     cmp.l    a1,a2
  676.     beq.s    doIT        running as resident
  677.     jmp    JumpIn-start+4(a2) Jump to JumpIn, but in the resident Code
  678. JumpIn    move.l    a1,d1    here it arrives
  679.     lsr.l    #2,d1
  680.     jsr    _LVOUnLoadSeg(a6)    free old mem
  681.     bra.s    doIT
  682. cresi    move.l    a1,d3
  683.     lsr.l    #2,d3
  684.     bsr    create_resi    make zshell resident
  685.     bne    crfail
  686.     addq.l    #1,resi_usecount(a2)
  687. doIT    bsr    shell            ***    DO IT    ***
  688.     bsr    deallocate_sets
  689.     bsr    reviewend
  690.     bsr    KillAppWin
  691.     bsr    RemoveCLI
  692.     lea    start-4(pc),a0
  693.     move.l    a0,d6
  694.     lsr.l    #2,d6
  695.     tst.b    noresi_flag(a5)
  696.     bne.s    normex
  697.     lea    ZShellName(pc),a4
  698.     bsr    search_res2
  699.     tst.l    d0
  700.     beq.s    crfail
  701.     subq.l    #1,resi_usecount(a0)
  702.     tst.l    d7
  703.     bne.s    crfail
  704.     moveq    #1,d1
  705.     cmp.l    resi_usecount(a0),d1
  706.     bne.s    crfail
  707.     move.l    d0,d6    kill the ZShell-Resident
  708.     move.l    a0,a2
  709.     move.l    d2,a0
  710.     move.l    resi_link(a2),resi_link(a0)
  711.     clr.l    resi_link(a2)
  712.     move.l    a2,d1
  713.     lsr.l    #2,d1
  714.     jsr    _LVOUnLoadSeg(a6)
  715. normex    bsr    giveman        free manualmem
  716.     move.l    thistask(a5),a0
  717.     tst.b    CLIflag(a5)    How to UnLoad the Segment
  718.     beq.s    .A
  719.     move.l    pr_SegList(a0),d0
  720.     beq.s    .B
  721.     lsl.l    #2,d0
  722.     move.l    d0,a0
  723.     move.l    d6,12(a0)    Store Segment in SegPointer (WB/RUN)
  724. .B    move.l    wb_msg(a5),d0
  725.     beq.s    crfail
  726.     move.l    d0,a0
  727.     move.l    d6,sm_Segment(a0)    and in Seg-Descriptor    (WB)
  728.     bra.s    crfail
  729. .A    move.l    pr_CLI(a0),a0
  730.     add.l    a0,a0
  731.     add.l    a0,a0
  732.     move.l    d6,cli_Module(a0)    Store Segment in Module    (CLI)
  733. crfail    move.l    dosbase(a5),a1
  734.     move.l    4.w,a6
  735.     jsr    _LVOCloseLibrary(a6)
  736. dosfail    move.l    intuibase(a5),a1
  737.     jsr    _LVOCloseLibrary(a6)
  738. intfail    move.l    wb_msg(a5),d2
  739.     move.l    a5,a1
  740.     move.l    #sizeofblk,d0
  741.     jsr    _LVOFreeMem(a6)
  742.     tst.l    d2
  743.     beq.s    .A
  744.     jsr    _LVOForbid(a6)    (what for ?)
  745.     move.l    d2,a1        WB-Message
  746.     jmp    _LVOReplyMsg(a6)    never returns !
  747. .A    moveq    #0,d0
  748.     rts
  749. blkfail    moveq    #RETURN_ERROR,d0
  750.     rts
  751.  
  752. initialise_default
  753.     move.l    CLIptr(a5),a0
  754.     moveq    #16,d0
  755.     move.l    d0,cli_FailLevel(a0)
  756.     move.b    #LF,past(a5)
  757.     lea    prompt_args_tx(pc),a0    init prompt
  758.     lea    prompt_args(a5),a1
  759. .C    move.b    (a0)+,(a1)+
  760.     bne.s    .C
  761.     moveq    #ctrl_inite-ctrl_init-1,d0
  762.     lea    ctrl_init(pc),a0
  763.     lea    ctrl_codes(a5),a1
  764. .B    move.b    (a0)+,(a1)+        init ctrl-codes
  765.     dbra    d0,.B
  766.     rts
  767.  
  768. InitAppWin
  769.     tst.l    ConsoleSwitch(a5)    test noraw-mode
  770.     beq.s    .A
  771.     move.l    4.w,a6
  772.     jsr    _LVOCreateMsgPort(a6)    get msg-port
  773.     move.l    d0,appwinport(a5)
  774.     beq.s    .A
  775.     move.l    d0,a2
  776.     move.l    dosbase(a5),a6
  777.     bsr    GetWindowPtr        get ptr to window
  778.     move.l    a0,d2
  779.     beq.s    .A
  780.     bsr    OpenWBLib
  781.     beq    .A
  782.     moveq    #0,d0
  783.     moveq    #0,d1
  784.     move.l    d2,a0
  785.     sub.l    a1,a1
  786.     exg.l    a1,a2
  787.     jsr    _LVOAddAppWindowA(a6)    make appwin
  788.     move.l    d0,appwindow(a5)
  789. .A    move.l    dosbase(a5),a6
  790.     rts
  791.  
  792. GetWindowPtr    ;pointer to Console-Window to a0 (0 for fail)
  793.     move.l    thistask(a5),a0
  794.     move.l    pr_ConsoleTask(a0),packettask(a5)
  795.     bsr    GetDiskInfo
  796.     sub.l    a0,a0
  797.     tst.l    sp_res1(a5)
  798.     beq.s    .A
  799.     move.l    id_VolumeNode(a5),a0    it is in here !
  800. .A    rts
  801.  
  802. KillAppWin
  803.     move.l    appwindow(a5),d2
  804.     beq.s    .B
  805.     bsr    OpenWBLib
  806.     move.l    d2,a0
  807.     jsr    _LVORemoveAppWindow(a6)
  808. .B    move.l    appwinport(a5),d0
  809.     beq.s    .A
  810.     move.l    d0,a0
  811.     move.l    4.w,a6
  812.     jsr    _LVODeleteMsgPort(a6)
  813. .A    move.l    dosbase(a5),a6
  814.     rts
  815.  
  816. * PRINT DECIMAL print D0 as decimal
  817. print10    movem.l    d0/a0-a1,-(sp)
  818.     move.l    d0,-(sp)
  819.     move.l    sp,a1
  820.     lea    format(pc),a0
  821.     bsr    new_print
  822.     addq.l    #4,sp
  823.     movem.l    (sp)+,d0/a0-a1
  824.     rts
  825.  
  826. * PRINT HEXADECIMAL address in D0
  827. printADR movem.l    d0/a0-a1,-(sp)
  828.     move.l    d0,-(sp)
  829.     move.l    sp,a1
  830.     lea    formatADR(pc),a0
  831.     bsr    new_print
  832.     addq.l    #4,sp
  833.     movem.l    (sp)+,d0/a0-a1
  834.     rts
  835.  
  836. *PRINT STRING at a1    ;saves some of the important low registers
  837. pr_space lea    space(pc),a1
  838.     bra.s    pr_string
  839. pr_tab    lea tab(pc),a1
  840.     bra.s pr_string
  841. pr_prompt lea prompt_string(a5),a1
  842.     bra.s pr_string    
  843. pr_lf    lea lf(pc),a1
  844. pr_string movem.l    d0-d3/a0-a3,-(sp)    print String in a1
  845.     move.l    a1,d2
  846.     moveq    #-1,d3
  847. .A    addq.l    #1,d3
  848.     tst.b    (a1)+
  849.     bne.s    .A
  850.     move.l    outhandle(a5),d1
  851.     beq.s    .B
  852.     jsr    _LVOWrite(a6)
  853. .B    movem.l    (sp)+,d0-d3/a0-a3
  854.     rts
  855.  
  856. pr_error
  857.     move.l    outhandle(a5),d1
  858.     move.l    stdout(a5),outhandle(a5)
  859.     bsr    pr_string
  860.     move.l    d1,outhandle(a5)
  861.     rts
  862.  
  863. *CHECK WHETHER A SCRIPT NAME WAS TYPED ON ENTRY TO ZSHELL
  864. execscr    move.l    EntryA0(a5),d0
  865.     move.l    d0,parm1(a5)
  866.     beq.s    .C
  867.     move.l    d0,a0
  868.     tst.b    (a0)
  869.     bne    xz2    ;NB this is OK, xz2 will pop the return addr 
  870.             ;and jump to chorus
  871.     rts
  872. .C    moveq    #-1,d1        handle DEFAULT SCRIPT FILE s:zstart
  873.     bsr    changeWindowPtr    disable volume requesters
  874.     lea    defscript(pc),a2
  875.     move.l    a2,d1
  876.     moveq    #ACCESS_READ,d2
  877.     jsr    _LVOLock(a6)
  878.     tst.l    d0
  879.     beq.s    .B
  880.     move.l    d0,d1
  881.     jsr    _LVOUnLock(a6)
  882.     move.l    a2,a0
  883.     moveq    #0,d1
  884.     bsr    changeWindowPtr
  885.     bra    xz2
  886. .B    moveq    #0,d1
  887.     bsr    changeWindowPtr
  888.     rts
  889.  
  890. CheckForbid
  891.     move.l    4.w,a0        Check for not closed
  892.     moveq    #-1,d0
  893.     cmp.b    294(a0),d0    Disables or
  894.     bne.s    .A
  895.     cmp.b    295(a0),d0    Forbids
  896.     beq.s    .B
  897. .A    move.b    d0,294(a0)    and avoids crashes !
  898.     move.b    d0,295(a0)
  899.     lea    Forbidtx(pc),a1
  900.     bsr    pr_stringlf
  901. .B    rts
  902.  
  903. *********************************
  904. *    MAIN BIT        *
  905. *********************************
  906. shell    move.l    sp,errorstack(a5)
  907.     lea    appicontx(pc),a0
  908.     move.l    a0,app_name(a5)
  909.     move.l    #%111010010,Flags(a5)
  910.     bsr    CreateCLI
  911.     bne    cloga            exit on error
  912.     move.l    thistask(a5),a3
  913.     move.l    pr_CLI(a3),a2
  914.     add.l    a2,a2
  915.     add.l    a2,a2
  916.     move.l    a2,CLIptr(a5)
  917.     move.l    cli_Prompt(a2),old_prompt(a5)
  918.     lea    prompt_args(a5),a0
  919.     move.l    a0,d0
  920.     lsr.l    #2,d0
  921.     move.l    d0,cli_Prompt(a2)
  922.     move.l    cli_SetName(a2),old_setname(a5)
  923.     lea    CD_string(a5),a0
  924.     move.l    a0,d0
  925.     lsr.l    #2,d0
  926.     move.l    d0,cli_SetName(a2)
  927.     cmp.w    #36,kickver(a5)
  928.     blo.s    .C
  929.     move.l    pr_HomeDir(a3),old_homedir(a5)
  930.     clr.l    pr_HomeDir(a3)
  931.     move.l    dl_Root(a6),a0
  932.     bset    #24,rn_Flags(a0)    set wildstar flag
  933.     bsr    InitAppWin
  934. .C    jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  935.     move.l    d0,outhandle(a5)
  936.     move.l    d0,stdout(a5)
  937.     jsr    _LVOInput(a6)
  938.     move.l    d0,inhandle(a5)
  939.     move.l    d0,stdin(a5)
  940.     move.l    pr_CurrentDir(a3),d1
  941.     jsr    _LVODupLock(a6)
  942.     move.l    d0,cdback(a5)
  943.     cmp.b    #1,WBflag(a5)
  944.     beq.s    notini        run/newcli
  945.     bsr    initialise_default
  946. notini    lea    pr_TaskNum(a3),a1
  947.     lea    welcome(pc),a0
  948.     bsr    new_print
  949.     bsr    eval_CD
  950.     IFND    DEBUG
  951.     bsr    execscr    
  952.     ENDC
  953. chorus    bsr    CheckForbid    HERE BEGINS THE MAIN LOOP
  954.     bsr    close_redirection
  955.     bsr    raw_on        MAKE SURE RAW MODE IS ON
  956.     clr.b    noreview_flag(a5)
  957.     bsr    compose_prompt
  958.     bsr    get_line
  959.     clr.b    break_flag(a5)
  960.     move.l    4.w,a6
  961.     moveq    #0,d0        clear signals c&d
  962.     moveq    #0,d1
  963.     bset    #SIGBREAKB_CTRL_C,d1
  964.     bset    #SIGBREAKB_CTRL_D,d1
  965.     jsr    _LVOSetSignal(a6)
  966.     move.l    dosbase(a5),a6
  967.     clr.b    forcediskflag(a5)
  968.     move.l    parm1(a5),a0
  969.     move.b    (a0),d0
  970.     cmp.b    ctrl_codes+15(a5),d0
  971.     bne.s    .A
  972.     addq.l    #1,a0
  973.     tst.b    (a0)
  974.     bne.s    .B
  975.     move.l    cdback(a5),d1    dir back
  976.     jsr    _LVODupLock(a6)
  977.     move.l    d0,d1
  978.     bsr    chdir
  979.     bra.s    chorus
  980. .B    move.l    a0,parm1(a5)
  981.     addq.b    #1,forcediskflag(a5)
  982.     bra    notfound    force disk-command
  983. .A    cmp.b    #"#",(a0)    #-sign for ;#comment
  984.     beq    chorus
  985.     move.l    a0,d7        check for ? (help sign)
  986.     tst.b    1(a0)
  987.     bne.s    .C
  988.     cmp.b    #"?",(a0)
  989.     bne.s    .C
  990.     bsr    help_man    ? as command
  991.     bra    chorus
  992. .C    lea    comtext(pc),a1
  993.     lea    comoffs(pc),a2
  994. mtch    bsr    match
  995.     tst.l    d0
  996.     beq.s    notfound
  997.     move.l    parm1(a5),d7        check for ? (help sign)
  998.     move.l    parm2(a5),a1
  999.     tst.b    1(a1)
  1000.     bne.s    .D
  1001.     cmp.b    #"?",(a1)
  1002.     bne.s    .D
  1003.     bsr    rawh_off
  1004.     bsr    help_man    ? as arg
  1005.     bra    chorus
  1006. .D    move.l    sp,errorstack(a5)    important in scripts ?
  1007.     lea    start(pc),a0
  1008. intern    jsr    0(a0,d0.w)    call internal command
  1009.     tst.b    break_flag(a5)
  1010.     bne.s    com_break
  1011. chkfail    move.l    d0,last_failcode(a5)
  1012.     move.l    CLIptr(a5),a0
  1013.     cmp.l    cli_FailLevel(a0),d0    ALL COMMANDS MUST RETURN D0=0 unless failure
  1014.     blo    chorus
  1015. com_fail move.l    d0,-(sp)
  1016.     move.l    sp,a1
  1017.     lea    failertx(pc),a0
  1018.     bsr    new_print
  1019.     move.l    (sp)+,d0
  1020. com_break clr.b    mult_comm_flag(a5)
  1021.     tst.b    scflag(a5)
  1022.     beq    chorus
  1023.     bsr    kill_script
  1024.     bra    chorus
  1025. notfound bsr    archie3        TRY DISK
  1026.     move.l    d0,-(sp)
  1027.     move.l    thistask(a5),a0
  1028.     move.l    cd_volnode(a5),d0
  1029.     move.l    pr_CurrentDir(a0),a1
  1030.     add.l    a1,a1
  1031.     add.l    a1,a1
  1032.     cmp.l    fl_Volume(a1),d0    check volume node
  1033.     bne.s    .A
  1034.     move.l    cd_block(a5),d0
  1035.     cmp.l    fl_Key(a1),d0    check disk block number
  1036.     beq.s    .B
  1037. .A    bsr    eval_CD        If command changes cd then change prompt.
  1038. .B    move.l    (sp)+,d0
  1039.     bra.s    chkfail
  1040.  
  1041.     
  1042. *Match the string pointed to by A0 to one in a table pted to by a1
  1043. *The number of the matched string is linked to an offset table pted to by
  1044. *A2.  return with 
  1045. *D0 holding offset from 'start' so a jsr 0(a0,d0.w) can be done
  1046. *Entry    A1 pts to Command text table  A2 pts to command offset table
  1047.  
  1048. match    moveq    #0,d1    ;command count
  1049.     move.l    a0,a3    ;save command
  1050. mat2    move.b    (a0)+,d0
  1051.     cmp.b    ctrl_codes+15(a5),d0    ;check "."
  1052.     bne.s    .A
  1053.     tst.b    (a0)
  1054.     beq.s    foundit    ;shortcut
  1055. .A    cmp.b    (a1),d0    ;V1.01
  1056.     beq.s    mat3
  1057.     add.b    #$20,d0    ;'A' -> 'a'    handle commands typed in UCase
  1058.     cmp.b    (a1),d0
  1059.     bne.s    nextcom    ;if any character wrong then check next
  1060. mat3    addq.l    #1,a1
  1061.     tst.b    -1(a0)    ;check whether 0 was last compared
  1062.     beq.s    foundit    ;if it was then success
  1063.     bra.s    mat2
  1064. nextcom    tst.b    (a1)+
  1065.     bne.s    nextcom
  1066.     addq.l    #2,d1    ;each offset is a word
  1067.     move.l    a3,a0
  1068.     tst.b    (a1)    ;put 0,0 at end of com table
  1069.     bne.s    mat2
  1070.     moveq    #0,d0    ;D0 = 0 if command not found
  1071.     rts
  1072. foundit    move.w    0(a2,d1.l),d0    ;get offset
  1073.     rts
  1074.  
  1075.  
  1076. * Subroutine for complet, limiting chars:":","/","""," " *
  1077. cjk1    cmp.b    #":",-1(a1)
  1078.     beq.s    cjke
  1079.     cmp.b    #"/",-1(a1)
  1080.     beq.s    cjke
  1081. cjk2    cmp.b    #$22,-1(a1)
  1082.     beq.s    cjke
  1083.     cmp.b    #" ",-1(a1)
  1084. cjke    rts
  1085.  
  1086. * Complete Filename in Shelline *
  1087. * a2 points to part of filename, d6 length of part *
  1088. * d4: linmax , d5:linhere *
  1089. complet    clr.b    temp2buf(a5)
  1090.     lea    shelline(a5),a1
  1091.     move.l    a1,a0
  1092.     move.l    d5,d6
  1093.     beq.s    .B
  1094.     add.l    d5,a1
  1095.     bsr    cjk1
  1096.     beq.s    .B        ;.C
  1097. .A    subq.l    #1,a1        look for begin of filename
  1098.     cmp.l    a1,a0
  1099.     beq.s    .B    
  1100.     bsr    cjk1
  1101.     bne.s    .A
  1102. .B    move.l    a1,a2        filename-pos. in a2
  1103.     sub.l    a0,a1
  1104.     sub.l    a1,d6        length in d6
  1105.     move.b    (a2),d3        save char
  1106.     clr.b    (a2)        null-end pathname
  1107.     move.l    a2,a1
  1108.     bra.s    .F
  1109. .D    subq.l    #1,a1        look for begin of path
  1110. .F    cmp.l    a1,a0
  1111.     beq.s    .E
  1112.     bsr    cjk2
  1113.     bne.s    .D
  1114. .E    move.l    a1,d1
  1115.     moveq    #-2,d2
  1116.     jsr    _LVOLock(a6)    lock path
  1117.     move.b    d3,(a2)        replace null-char by old one
  1118.     move.l    d0,d7        save lock
  1119.     beq.s    .C
  1120.     bsr    fibexam2
  1121.     moveq    #0,d3
  1122.     tst.l    fib_DirEntryType(a5)
  1123.     bpl.s    wdhcpl        if plus,is directory
  1124. .G    move.l    d7,d1
  1125.     jsr    _LVOUnLock(a6)
  1126. .C    rts            an error occured
  1127. wdhcpl    bsr    fibexnx        repeat to search whole dir
  1128.     tst.l    d0        next filename or dirname
  1129.     beq    endcpl
  1130.     lea    fib_FileName(a5),a0
  1131.     move.l    a0,a3
  1132.     lea    ignoreit(a5),a1
  1133.     tst.b    (a1)
  1134.     beq.s    .F
  1135.     bsr    wildmatch        wildcheck
  1136.     tst.b    d0
  1137.     beq.s    wdhcpl
  1138. .F    move.l    a3,a0
  1139.     move.l    a2,a1
  1140.     move.l    d6,d2
  1141.     bra.s    .I
  1142. .A    move.b    (a0)+,d0
  1143.     move.b    (a1)+,d1
  1144.     bsr    compD1D0nocase        does it fit ?
  1145.     bne.s    wdhcpl
  1146. .I    dbra    d2,.A
  1147.     lea    temp2buf(a5),a0
  1148.     tst.l    d3
  1149.     bne.s    .B
  1150. .C    move.b    (a3)+,(a0)+    ! first time: copy filename !
  1151.     bne.s    .C
  1152.     move.b    #" ",-1(a0)    add a space at the end (files)
  1153.     clr.b    (a0)
  1154.     tst.l    fib_DirEntryType(a5)
  1155.     bmi.s    .E        if plus,is directory
  1156.     move.b    #"/",-1(a0)    add a / at the end (dirs)
  1157. .E    moveq    #1,d3
  1158.     bra.s    wdhcpl
  1159.  
  1160. .B    btst    #FLmatch,Flags+3(a5)    ! next time !
  1161.     beq.s    .G
  1162.     tst.l    d3
  1163.     bmi.s    .G
  1164.     moveq    #-1,d3
  1165.     lea    hide_cursor(pc),a1
  1166.     bsr    pr_stringlf    print first time
  1167.     lea    temp2buf(a5),a1
  1168.     bsr    pr_string
  1169.     bsr    pr_space
  1170. .G    move.b    (a0)+,d0
  1171.     move.b    (a3)+,d1
  1172.     bsr    compD1D0nocase    next time: find longest common part
  1173.     bne.s    .D
  1174.     tst.b    -1(a0)
  1175.     beq.s    .D
  1176.     tst.b    -1(a3)
  1177.     bne.s    .G
  1178. .D    clr.b    -1(a0)
  1179.     btst    #FLmatch,Flags+3(a5)
  1180.     beq    wdhcpl
  1181.     lea    fib_FileName(a5),a1
  1182.     lea    tempbuf(a5),a0
  1183. .J    move.b    (a1)+,(a0)+
  1184.     bne.s    .J
  1185.     move.b    #" ",-1(a0)
  1186.     tst.l    fib_DirEntryType(a5)
  1187.     bmi.s    .H        if plus,is directory
  1188.     move.b    #"/",-1(a0)
  1189. .H    move.b    #" ",(a0)+
  1190.     clr.b    (a0)
  1191.     lea    tempbuf(a5),a1
  1192.     bsr    pr_string    print other times
  1193.     bra    wdhcpl        repeat with all filenames
  1194.  
  1195. endcpl    move.l    d7,d1
  1196.     jsr    _LVOUnLock(a6)
  1197.     btst    #FLmatch,Flags+3(a5)
  1198.     beq    .I
  1199.     tst.l    d3        next time
  1200.     bpl.s    .I
  1201.     lea    show_cursor(pc),a1
  1202.     bsr    pr_stringlf
  1203. .I    lea    temp2buf(a5),a0
  1204.     moveq    #-1,d3
  1205. .G    addq.l    #1,d3
  1206.     tst.b    (a0)+
  1207.     bne.s    .G
  1208.     subq.l    #1,a0
  1209.     sub.l    d6,d3        D3=length
  1210.     bmi.s    DisplayBeep
  1211.     cmp.w    #SHELLINE_SIZE-2,d4    make sure line is not too long
  1212.     bhi.s    DisplayBeep
  1213.     lea    shelline(a5),a1    ethel
  1214.     lea    1(a1,d4.w),a3    A3=linmax
  1215.     move.l    a3,a2
  1216.     add.l    d3,a2        A2=linmax+length
  1217.     lea    0(a1,d5.w),a1    linhere
  1218. .A    move.b    -(a3),-(a2)    insert chars into shelline
  1219.     cmp.l    a3,a1
  1220.     bne.s    .A
  1221.     move.l    d3,d0
  1222.     add.l    d6,d0    
  1223.     bra.s    .C
  1224. .D    move.b    -(a0),-(a2)    copy found filename
  1225. .C    dbra    d0,.D
  1226.     add.l    d3,d5
  1227.     add.l    d3,d4
  1228.     bsr    gimme3        print shelline
  1229.     move.l    d4,d0
  1230.     sub.l    d5,d0
  1231.     lea    tempbuf(a5),a1
  1232.     move.l    a1,a0
  1233.     bra.s    .E
  1234. .F    move.w    #$9b<<8+"D",(a0)+    left cursor
  1235. .E    dbra    d0,.F        
  1236.     clr.b    (a0)
  1237.     bsr    pr_string    restore cursorpos
  1238. .B    rts
  1239. DisplayBeep
  1240.     move.l    intuibase(a5),a6
  1241.     suba.l    a0,a0
  1242.     jsr    _LVODisplayBeep(a6)
  1243.     move.l    dosbase(a5),a6
  1244.     rts
  1245.  
  1246.  
  1247. get_one_char
  1248.     bsr    GetWindowPtr
  1249.     move.l    a0,a3
  1250.     bsr    clearArgs
  1251.     move.l    inhandle(a5),myArg1(a5)
  1252.     lea    tempbytes(a5),a0
  1253.     move.l    a0,myArg2(a5)
  1254.     moveq    #1,d0
  1255.     move.l    d0,myArg3(a5)
  1256.     move.l    thistask(a5),a0
  1257.     move.l    pr_ConsoleTask(a0),packettask(a5)
  1258.     moveq    #ACTION_READ,d0
  1259.     move.l    d0,packettype(A5)
  1260.     bsr    sendpacket2    read keyboard with packets
  1261.     moveq    #0,d3
  1262.     move.l    thistask(a5),a0
  1263.     move.b    pr_MsgPort+MP_SIGBIT(a0),d1
  1264.     bset    d1,d3        set wait bit for reading
  1265.     move.l    appwinport(a5),d2
  1266.     beq.s    .A
  1267.     move.l    d2,a0
  1268.     move.b    MP_SIGBIT(a0),d1
  1269.     bset    d1,d3        set wait bit for appwindow
  1270. .A    move.l    d3,d0
  1271.     jsr    _LVOWait(a6)    wait for anything
  1272.     tst.l    d2
  1273.     beq.s    .B
  1274.     move.l    d2,a0
  1275.     jsr    _LVOGetMsg(a6)    try to get appwinmsg
  1276.     tst.l    d0
  1277.     beq.s    .B
  1278.     move.l    d0,a2
  1279.     bsr    ProcessApp    look at it
  1280.     move.l    a2,a1
  1281.     jsr    _LVOReplyMsg(a6)
  1282.     move.l    dosbase(a5),a6
  1283.     lea    tempbuf(a5),a1
  1284.     bsr    print_def    write iconname to shelline
  1285.     move.l    intuibase(a5),a6
  1286.     move.l    a3,a0
  1287.     jsr    _LVOActivateWindow(a6)
  1288. .C    move.l    4.w,a6
  1289.  
  1290. .B    move.l    thistask(a5),a0
  1291.     lea    pr_MsgPort(a0),a0
  1292.     jsr    _LVOGetMsg(a6)    try to get read-packet-reply
  1293.     move.l    d0,d1
  1294.     beq.s    .A
  1295.     move.l    dosbase(a5),a6
  1296.     lea    sp_node(a5),a0
  1297.     move.l    #212,d0
  1298.     cmp.l    d1,a0
  1299.     bne    pr_galactic    got wrong dospacket
  1300.     tst.l    sp_res1(a5)
  1301.     bmi.s    .D        error occured
  1302.     beq.s    .D
  1303.     move.b    tempbytes(a5),d6
  1304.     rts
  1305. .D    moveq    #20,d1
  1306.     bsr    GuruIt
  1307.     bra    cloga
  1308.  
  1309. saveundo
  1310.     lea    shelline(a5),a0
  1311.     lea    CLIbuf(a5),a1
  1312.     move.l    d4,d0
  1313.     bra.s    .B
  1314. .A    move.b    (a0)+,(a1)+
  1315. .B    dbra    d0,.A
  1316.     clr.b    (a1)
  1317.     rts
  1318.  
  1319. * A1 pts to past, d0=nost
  1320. gimme    lea    shelline(a5),a2
  1321.     move.l    d0,nost(a5)
  1322.     cmp.l    now(a5),d0
  1323.     bne.s    .C
  1324.     moveq    #-1,d4        reset linmax
  1325.     lea    CLIbuf(a5),a0
  1326. .D    addq.l    #1,d4
  1327.     move.b    (a0)+,(a2)+    copy undo to shelline
  1328.     bne.s    .D
  1329.     move.l    d4,d5        linmax=linhere
  1330.     bra    gimme3
  1331.  
  1332. .C    moveq    #0,d5        linhere = 0
  1333. .B    addq.l    #1,d0        copy to shelline
  1334.     and.l    #HISTORY_SIZE-1,d0
  1335.     cmp.b    #LF,0(a1,d0.l)
  1336.     beq.s    .A
  1337.     move.b    0(a1,d0.l),0(a2,d5.l)
  1338.     addq.l    #1,d5
  1339.     bra.s    .B
  1340. .A    move.l    d5,d4        linmax=linhere
  1341. gimme3    lea    shelline(a5),a2        Print input line newer
  1342.     lea    delete_line(pc),a1
  1343.     bsr    pr_string
  1344.     move.l    prompt_cr(a5),a1
  1345.     bsr    pr_string
  1346.     clr.b    0(a2,d4.l)    clear last
  1347.     move.l    a2,a1
  1348.     bra    pr_string
  1349.  
  1350.  
  1351. * READ TEXT LINE from keyboard or script into buffer pointed to by a0,
  1352. * and clear last byte. NOTE A0 is essentially ignored, and shelline is the
  1353. * assumed address. Return with a0 same, and d0=length of text read
  1354. type_in    tst.b    scflag(a5)        ;check whether we're doing a script
  1355.     bne    scr_in
  1356. type_in2
  1357.     move.l    a0,-(sp)
  1358.     tst.l    ConsoleSwitch(a5)
  1359.     bne.s    .A
  1360.     move.l    a0,a2            use console in cooked mode
  1361. .C    move.l    a2,d2
  1362.     move.l    inhandle(a5),d1
  1363.     beq    cloga
  1364.     move.l    #SHELLINE_SIZE,d3
  1365.     jsr    _LVORead(a6)
  1366.     tst.l    d0
  1367.     bmi    cloga
  1368.     beq    cloga
  1369.     clr.b    0(a2,d0.l)
  1370.     cmp.b    #LF,-1(a2,d0.l)
  1371.     bne.s    .C
  1372.     cmp.b    #LF,(a2)
  1373.     bne.s    .B
  1374.     bsr    pr_prompt
  1375.     bra.s    .C
  1376. .B    move.l    (sp)+,a0
  1377.     rts
  1378.     
  1379. .A    clr.b    CLIbuf(a5)    (for undo)
  1380.     moveq    #0,d5        D5=linhere    use console in raw mode
  1381.     moveq    #0,d4        D4=linmax
  1382. next_ch    bsr    get_one_char
  1383.     cmp.b    #$9b,d6
  1384.     bne    not_csi
  1385.     clr.l    gather_ptr(a5)
  1386. fetch_csi    bsr    get_one_char
  1387.     lea    gather(a5),a0
  1388.     move.l    gather_ptr(a5),d0
  1389.     move.b    d6,0(a0,d0.l)        ;save byte from CSI sequence.
  1390.     addq.l    #1,gather_ptr(a5)
  1391.     moveq    #40,d1
  1392.     cmp.l    d1,d0
  1393.     blo.s    .A
  1394.     clr.l    gather_ptr(a5)
  1395. .A    cmp.b    #'@',d6
  1396.     blo.s    fetch_csi        ;keep gathering if char < @
  1397.     cmp.b    #'~',d6
  1398.     bhi.s    fetch_csi        ;keep gathering if char > ~
  1399.  
  1400.     cmp.b    #"|",d6        CHECK CLOSE GADGET
  1401.     bne.s    not_cloga
  1402. cloga2    btst    #FLappicon,Flags+3(a5)
  1403.     beq.s    cloga        exit immediately
  1404.     tst.b    openwin_flag(a5)
  1405.     beq.s    cloga
  1406.     bsr    WaitAppIcon
  1407.     addq.b    #1,noreview_flag(a5)
  1408.     bsr    raw_on
  1409.     bsr    gimme3
  1410.     move.l    d4,d5
  1411.     bra    next_ch
  1412. cloga    move.l    dosbase(a5),a6    totally-exit-routine
  1413.     move.l    errorstack(a5),sp    ;kill return address on stack
  1414.     bsr    raw_off
  1415.     moveq    #-1,d7
  1416.     tst.b    scflag(a5)
  1417.     beq.s    .A
  1418.     bsr    kill_script
  1419. .A    rts
  1420.  
  1421. not_cloga
  1422.     cmp.b    #'D',d6        CHECK LEFT ARROW    <CSI>D
  1423.     bne.s    not_left
  1424.     tst.l    d5
  1425.     beq.s    not_left
  1426.     subq.l    #1,d5
  1427.     lea    left_cursor(pc),a1
  1428.     bsr    pr_string
  1429.     bra    next_ch
  1430.     
  1431. not_left    cmp.b    #'Z',d6    CHECK TAB & SHIFT    <CSI> Z
  1432.     bne.s    not_tab_left
  1433. v_buffer
  1434.     tst.l    ReviewSize(a5)
  1435.     beq    next_ch
  1436.     movem.l    d3-d7/a2-a4,-(sp)
  1437.     sub.l    a3,a3
  1438.     bsr    viewbuffer
  1439.     movem.l    (sp)+,d3-d7/a2-a4
  1440.     addq.b    #1,noreview_flag(a5)
  1441.     bsr    gimme3
  1442.     move.l    d4,d5
  1443.     bra    next_ch
  1444.  
  1445. not_tab_left    cmp.b    #'A',d6
  1446.     bne.s    not_sh_left
  1447.     cmp.b    #' ',gather(a5)    CHECK SHIFT LEFT ARROW    <CSI> A
  1448.     bne.s    not_sh_left
  1449.     move.l    d5,d0
  1450.     lea    tempbuf(a5),a1
  1451.     move.l    a1,a0
  1452.     bra.s    .A
  1453. .B    move.w    #$9b<<8+"D",(a0)+    left cursor
  1454. .A    dbra    d0,.B
  1455.     clr.b    (a0)
  1456.     bsr    pr_string
  1457.     moveq    #0,d5
  1458.     bra    next_ch
  1459.  
  1460. not_sh_left
  1461.     cmp.b    #'C',d6        CHECK RIGHT ARROW    <CSI>C
  1462.     bne.s    not_right
  1463.     cmp.l    d4,d5
  1464.     bhs.s    not_right
  1465.     addq.l    #1,d5
  1466.     lea    right_cursor(pc),a1
  1467.     bsr    pr_string
  1468.     bra    next_ch
  1469.  
  1470. not_right    cmp.b    #'@',d6
  1471.     bne.s    not_sh_right
  1472.     cmp.b    #' ',gather(a5)    CHECK SHIFT RIGHT ARROW    <CSI> @
  1473.     bne.s    not_sh_right
  1474.     move.l    d4,d0
  1475.     sub.l    d5,d0
  1476.     lea    tempbuf(a5),a1
  1477.     move.l    a1,a0
  1478.     bra.s    .A
  1479. .B    move.w    #$9b<<8+"C",(a0)+    right cursor
  1480. .A    dbra    d0,.B
  1481.     clr.b    (a0)
  1482.     bsr    pr_string
  1483.     move.l    d4,d5
  1484.     bra    next_ch
  1485.  
  1486. not_sh_right
  1487.     cmp.b    #'A',d6        CHECK UP ARROW
  1488.     bne.s    not_up
  1489.     lea    past(a5),a1
  1490.     move.l    nost(a5),d0
  1491.     cmp.l    then(a5),d0
  1492.     beq.s    .B
  1493. .A    subq.l    #1,d0
  1494.     and.l    #HISTORY_SIZE-1,d0        WRAP AROUND
  1495.     cmp.b    #LF,0(a1,d0.l)
  1496.     bne.s    .A
  1497. .B    bsr    gimme
  1498.     bra    next_ch
  1499.  
  1500. not_up    cmp.b    #'B',d6        CHECK DOWN ARROW
  1501.     bne.s    not_down
  1502. up_bit    lea    past(a5),a1    CALLED BY SHIFT DOWN BIT
  1503.     move.l    nost(a5),d0
  1504.     cmp.l    now(a5),d0
  1505.     beq.s    .B
  1506. .A    addq.l    #1,d0
  1507.     and.l    #HISTORY_SIZE-1,d0
  1508.     cmp.b    #LF,0(a1,d0.l)
  1509.     bne.s    .A
  1510. .B    bsr    gimme
  1511.     bra    next_ch
  1512.  
  1513. not_down    cmp.b    #'T',d6        CHECK SHIFT UP
  1514.     bne    not_sh_up
  1515.     lea    past(a5),a1
  1516.     tst.l    d5
  1517.     bne.s    search_his
  1518.     move.l    then(a5),nost(a5)    nost = then (the top)
  1519.     move.l    nost(a5),d0
  1520.     bsr    gimme
  1521.     bra    next_ch
  1522. search_his            ;search shelline in history    V2.0
  1523.     move.l    nost(a5),d0
  1524. .C    cmp.l    then(a5),d0
  1525.     bne.s    .A
  1526.     move.l    nost(a5),d0
  1527.     bra.s    end_seh
  1528. .A    subq.l    #1,d0
  1529.     and.l    #HISTORY_SIZE-1,d0
  1530.     cmp.b    #LF,0(a1,d0.l)
  1531.     bne.s    .A
  1532.  
  1533.     lea    shelline(a5),a0
  1534.     move.l    d5,d1
  1535.     subq.l    #1,d1
  1536.     move.l    d0,d2
  1537. .D    addq.l    #1,d2
  1538.     and.l    #HISTORY_SIZE-1,d2
  1539.     movem.l    d0/d1,-(sp)
  1540.     move.b    0(a1,d2.l),d0
  1541.     move.b    (a0),d1
  1542.     bsr    compD1D0nocase
  1543.     movem.l    (sp)+,d0/d1
  1544.     bne.s    .C
  1545.     addq.l    #1,a0
  1546.     dbra    d1,.D
  1547. end_seh    move.l    d5,d1        save d5
  1548.     bsr    gimme
  1549.     move.l    d5,d0
  1550.     sub.l    d1,d0
  1551.     bmi.s    .C
  1552.     lea    tempbuf(a5),a1
  1553.     move.l    a1,a0
  1554.     bra.s    .A
  1555. .B    move.w    #$9b<<8+"D",(a0)+    left cursor
  1556. .A    dbra    d0,.B
  1557.     clr.b    (a0)
  1558.     bsr    pr_string
  1559.     move.l    d1,d5
  1560. .C    bra    next_ch
  1561.  
  1562.  
  1563. not_sh_up    cmp.b    #'S',d6        CHECK SHIFT DOWN
  1564.     bne.s    not_sh_down
  1565.     move.l    now(a5),nost(a5)    nost = now (the bottom)
  1566.     bra    up_bit
  1567.     
  1568. not_sh_down            ;NOTE V1.05
  1569.     cmp.b    #'~',d6        CHECK FUNCTION KEYS AND HELP KEY
  1570.     bne    next_ch
  1571.     cmp.b    #'?',gather(a5)
  1572.     bne.s    process_the_func_key
  1573.     lea    help_ret(pc),a1
  1574.     move.l    d0,-(sp)    need crap on stack to call print_def
  1575.     bsr    print_def    will rip last 2 addrs off stack
  1576. * never gets to this line
  1577. process_the_func_key
  1578.     bsr    translate_func_key
  1579.     bra    next_ch
  1580.         
  1581. * Was not a CSI code
  1582. not_csi    cmp.b    ctrl_codes+6(a5),d6        CHECK ESCAPE (ctrl+[)
  1583.     beq    cloga2        exit immediately
  1584.  
  1585. not_esc    cmp.b    ctrl_codes+7(a5),d6    CHECK TAB (ctrl+I)
  1586.     bne.s    not_tab_right
  1587. .A    cmp.l    d4,d5
  1588.     bhs    next_ch
  1589.     addq.l    #1,d5
  1590.     lea    right_cursor(pc),a1
  1591.     bsr    pr_string
  1592.     lea    shelline-1(a5),a0
  1593.     bsr    tab_check
  1594.     bne.s    .A
  1595.     bra    next_ch
  1596.     
  1597. not_tab_right
  1598.     cmp.b    ctrl_codes+8(a5),d6        CHECK CTRL Y
  1599.     beq    v_buffer        same as shift&tab
  1600.  
  1601.     cmp.b    ctrl_codes+9(a5),d6        CHECK BACKSPACE (ctrl+H)
  1602.     bne.s    not_bs
  1603.     tst.l    d5
  1604.     beq.s    not_bs
  1605.     subq.l    #1,d5
  1606.     lea    backspace_it(pc),a1
  1607.     bsr    pr_string
  1608.     bsr    del_str
  1609.     bsr    saveundo
  1610.     bra    next_ch
  1611.  
  1612. del_str    lea    shelline(a5),a4
  1613.     lea    SHELLINE_SIZE+shelline(a5),a1    NOTE SHELLINE SIZE!!!
  1614.     lea    0(a4,d5.w),a0
  1615.     lea    1(a0),a2
  1616. .A    move.b    (a2)+,(a0)+
  1617.     cmp.l    a2,a1
  1618.     bne.s    .A
  1619.     subq.l    #1,d4
  1620.     rts
  1621.  
  1622. not_bs    cmp.b    #$7f,d6                CHECK DELETE
  1623.     bne.s    not_del
  1624.     cmp.l    d4,d5
  1625.     bhs.s    not_del
  1626.     lea    delete_it(pc),a1
  1627.     bsr    pr_string
  1628.     bsr    del_str
  1629.     bsr    saveundo
  1630.     bra    next_ch
  1631.     
  1632. not_del    cmp.b    ctrl_codes+5(a5),d6        CHECK CTRL X
  1633.     bne.s    not_ctrlx
  1634.     bsr    saveundo
  1635.     moveq    #0,d5        delete shelline
  1636.     moveq    #0,d4
  1637.     bsr    gimme3
  1638.     bra    next_ch
  1639.     
  1640. not_ctrlx
  1641.     cmp.b    ctrl_codes+3(a5),d6        CHECK CTRL E
  1642.     bne.s    not_ctrle
  1643. .A    cmp.l    d4,d5        delete to end of line
  1644.     bhs.s    .B
  1645.     lea    delete_it(pc),a1
  1646.     bsr    pr_string
  1647.     bsr    del_str
  1648.     bra.s    .A
  1649. .B    bsr    saveundo
  1650.     bra    next_ch
  1651.     
  1652. not_ctrle
  1653.     cmp.b    ctrl_codes+2(a5),d6        CHECK CTRL S
  1654.     bne.s    not_ctrls
  1655. .A    tst.l    d5        delete to start of line
  1656.     beq.s    .B
  1657.     subq.l    #1,d5
  1658.     lea    backspace_it(pc),a1
  1659.     bsr    pr_string
  1660.     bsr    del_str
  1661.     bra.s    .A
  1662. .B    bsr    saveundo
  1663.     bra    next_ch
  1664.     
  1665. not_ctrls
  1666.     cmp.b    ctrl_codes+1(a5),d6        CHECK CTRL W
  1667.     bne.s    not_ctrlw
  1668. .A    tst.l    d5        delete last word
  1669.     beq    next_ch
  1670.     subq.l    #1,d5
  1671.     lea    backspace_it(pc),a1
  1672.     bsr    pr_string
  1673.     bsr    del_str
  1674.     lea    shelline-1(a5),a0
  1675.     bsr    tab_check
  1676.     bne.s    .A
  1677.     bsr    saveundo
  1678.     bra    next_ch
  1679.  
  1680. not_ctrlw
  1681.     cmp.b    ctrl_codes+0(a5),d6        CHECK CTRL Q
  1682.     bne.s    not_ctrlq
  1683. .A    cmp.l    d4,d5        delete next word
  1684.     bhs    next_ch
  1685.     lea    delete_it(pc),a1
  1686.     bsr    pr_string
  1687.     bsr    del_str
  1688.     lea    shelline+0(a5),a0
  1689.     bsr    tab_check
  1690.     bne.s    .A
  1691.     bsr    saveundo
  1692.     bra    next_ch
  1693.  
  1694. not_ctrlq
  1695.     cmp.b    ctrl_codes+4(a5),d6        CHECK CTRL A
  1696.     bne.s    not_ctrla
  1697.     movem.l    d3/d6/d7/a3,-(sp)
  1698.     bsr    complet        complete filename
  1699.     movem.l    (sp)+,d3/d6/d7/a3
  1700.     bsr    saveundo
  1701.     bra    next_ch
  1702.  
  1703. not_ctrla
  1704.     cmp.b    ctrl_codes+10(a5),d6        CHECK CTRL J
  1705.     bne.s    not_ctrlj
  1706.     bsr    do_cr2
  1707.     move.l    errorstack(a5),sp
  1708.     bra    chorus
  1709.  
  1710. not_ctrlj
  1711.     cmp.b    ctrl_codes+12(a5),d6        CHECK CTRL L
  1712.     bne.s    not_ctrll
  1713.     lea    clrtx(pc),a1
  1714.     bsr    pr_string    clear window
  1715.     bsr    gimme3
  1716.     move.l    d4,d5
  1717.     bra    next_ch
  1718.  
  1719. not_ctrll
  1720.     cmp.b    ctrl_codes+13(a5),d6        CHECK CTRL R
  1721.     bne.s    not_ctrlr
  1722. tab_left tst.l    d5
  1723.     beq    next_ch
  1724.     subq.l    #1,d5
  1725.     lea    left_cursor(pc),a1
  1726.     bsr    pr_string
  1727.     lea    shelline-1(a5),a0
  1728.     bsr    tab_check
  1729.     bne.s    tab_left
  1730.     bra    next_ch
  1731.  
  1732. tab_check cmp.b    #' ',(a0,d5.w) words are separated by / . : or space
  1733.     beq.s    .A
  1734.     cmp.b    #':',(a0,d5.w)
  1735.     beq.s    .A
  1736.     cmp.b    #'.',(a0,d5.w)
  1737.     beq.s    .A
  1738.     cmp.b    #'/',(a0,d5.w)
  1739. .A    rts
  1740.  
  1741. not_ctrlr
  1742.     cmp.b    ctrl_codes+14(a5),d6        CHECK CTRL V
  1743.     bne.s    not_ctrlv
  1744.     movem.l    d3-d7/a2-a4,-(sp)
  1745.     lea    past(a5),a2
  1746.     move.l    now(a5),d3
  1747.     move.l    #HISTORY_SIZE,d2
  1748.     sub.l    a3,a3
  1749.     bsr    viewhist
  1750.     movem.l    (sp)+,d3-d7/a2-a4
  1751.     addq.b    #1,noreview_flag(a5)
  1752.     bsr    gimme3
  1753.     move.l    d4,d5
  1754.     bra    next_ch
  1755.  
  1756. not_ctrlv
  1757.     cmp.b    ctrl_codes+11(a5),d6        CHECK CTRL M
  1758.     beq.s    do_cr
  1759.     cmp.b    #13,d6        CHECK CR
  1760.     bne    no_cr
  1761. do_cr    move.l    (sp)+,a2
  1762. do_cr2    lea    return_it(pc),a1
  1763.     bsr    pr_string
  1764.     lea    shelline(a5),a4
  1765.     move.b    #LF,0(a4,d4.w)    HACK JOB    (MUST END IN LF 0)
  1766.     clr.b    1(a4,d4.w)    FOR ALIAS STUFF
  1767.     tst.l    d4        CHECK IF NOTHING TYPED
  1768.     bne.s    history_it
  1769.     bsr    pr_prompt        IF JUST HIT RETURN, THEN START AGAIN
  1770.     move.l    a2,a0
  1771.     bra    type_in2
  1772. history_it
  1773.     lea    past(a5),a1    CHECK IF LAST ENTRY IS SAME AS CURRENT
  1774.     move.l    now(a5),d0
  1775.     cmp.l    then(a5),d0
  1776.     beq.s    .B
  1777.     move.l    d0,nost(a5)
  1778. .A    subq.l    #1,d0        FIND LAST
  1779.     and.l    #HISTORY_SIZE-1,d0    WRAP AROUND
  1780.     cmp.b    #LF,0(a1,d0.l)
  1781.     bne.s    .A
  1782.     lea    (a4),a0
  1783.     bra.s    .C
  1784. .D    cmp.b    #LF,d1        COMPARE LAST TO SHELLINE
  1785.     beq    finland
  1786. .C    addq.l    #1,d0
  1787.     and.l    #HISTORY_SIZE-1,d0
  1788.     move.b    (a0)+,d1
  1789.     cmp.b    0(a1,d0.l),d1
  1790.     beq.s    .D
  1791.  
  1792. .B    move.l    a4,a3    lin    COPY LINE TO HISTORY  BUFFER
  1793.     move.l    now(a5),d3    pts to the last LF
  1794.  
  1795. .E    addq.l    #1,d3
  1796.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  1797.     move.b    (a3)+,d0
  1798.     move.b    d0,0(a1,d3.l)
  1799.     cmp.b    #LF,d0
  1800.     bne.s    .E
  1801. ;dumped_hist
  1802.     move.l    d3,nost(a5)    nost = now
  1803.     move.l    d3,now(a5)
  1804.     move.l    then(a5),d1
  1805.     cmp.b    #LF,0(a1,d1.l)
  1806.     bne.s    .G    BRANCH IF WRAPPED AROUND
  1807.     cmp.l    d3,d1
  1808.     bne.s    finland    BRANCH IF THEN = (10) & THEN <> NOW
  1809. .G    
  1810. *    move.l    d3,then(a5)    then=now
  1811. .H    addq.l    #1,d3    SEARCH FOR NEXT LF (NEW TOP OF HISTORY)
  1812.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  1813.     move.b    0(a1,d3.l),d0
  1814.     cmp.b    #LF,d0
  1815.     bne.s    .H        ***
  1816.     move.l    d3,then(a5) SET NEW THEN (TOP OF HISTORY)
  1817.  
  1818. ******* 
  1819. finland    tst.b    scflag(a5)
  1820.     bne.s    .D
  1821.     lea    prompt_string(a5),a1    write to review-buffer
  1822.     move.l    a1,d2
  1823.     moveq    #-1,d3
  1824. .E    addq.l    #1,d3
  1825.     tst.b    (a1)+
  1826.     bne.s    .E
  1827.     bsr    toreview
  1828.     move.l    a2,d2
  1829.     move.l    d4,d3
  1830.     addq.l    #1,d3
  1831.     bsr    toreview
  1832. .D    move.l    a2,a0
  1833.     move.l    d4,d0
  1834.     rts
  1835.  
  1836. no_cr    cmp.b    #" ",d6    
  1837.     blo.s    .A
  1838.     cmp.b    #127,d6
  1839.     bls.s    .B
  1840.     cmp.b    #160,d6
  1841.     blo.s    .A
  1842. .B    bsr    ins_char
  1843.     bsr    saveundo
  1844. .A    bra    next_ch
  1845.  
  1846. * insert a char in the shelline
  1847. ins_char cmp.w    #SHELLINE_SIZE-2,d4    make sure line is not too long
  1848.     bhi.s    .B
  1849.     lea    tempbuf(a5),a1
  1850.     move.w    #$9b<<8+"@",(a1)
  1851.     clr.b    3(a1)
  1852.     move.b    d6,2(a1)    shove printable char after insert seq
  1853.     bsr    pr_string        insert space for char
  1854.     lea    shelline(a5),a1    ethel
  1855.     lea    1(a1,d4.w),a0    linmax
  1856.     lea    1(a0),a2        A2=linmax+1
  1857.     lea    0(a1,d5.w),a1    linhere
  1858. .A    move.b    -(a0),-(a2)    insert char into shelline
  1859.     cmp.l    a0,a1
  1860.     bne.s    .A
  1861.     lea    shelline(a5),a4
  1862.     move.b    d6,0(a4,d5.w)
  1863.     addq.l    #1,d5
  1864.     addq.l    #1,d4
  1865. .B    rts
  1866.  
  1867. * TRANSLATE FUNC CODE TO F1,F2 ETC AND SET UP POINTERS
  1868. translate_func_key
  1869.     lea    gather(a5),a0
  1870.     move.l    gather_ptr(a5),d0
  1871.     cmp.b    #3,d0        CHECK IF TWO CODES EG '12'
  1872.     beq    process_shift_func
  1873. unshifted_func_key
  1874.     cmp.b    #2,d0
  1875.     bne    translate_func_fail
  1876.     move.b    (A0),d0
  1877.     moveq    #'f',d1
  1878. act_sh    bsr    convert_to_set_name
  1879.     bsr    search_sets    returns D0 pointer to set
  1880.     bsr    print_func_defn
  1881.     rts
  1882. process_shift_func
  1883.     move.b    1(A0),d0
  1884.     moveq    #'F',d1
  1885.     bra.s    act_sh
  1886. translate_func_fail
  1887.     rts
  1888.  
  1889. *d0=set ptr
  1890. print_func_defn
  1891.     tst.l    d0
  1892.     beq    do_not_print_func
  1893.     move.l    d0,a1
  1894.     lea    set_defn(a1),a1
  1895. print_def    lea    shelline(a5),a2
  1896.     bra.s    .B
  1897. .A    addq.l    #1,d5        copy defn to shelline
  1898. .B    move.b    (a1)+,0(a2,d5.l)
  1899.     bne.s    .A
  1900.     cmp.b    #'M',-1(a2,d5.l)    check for auto return ^M
  1901.     bne.s    .C
  1902.     cmp.b    #'^',-2(a2,d5.l)
  1903.     bne.s    .C
  1904.     subq.l    #2,d5
  1905.     move.l    d5,d4
  1906.     bsr    gimme3        print it
  1907.     movem.l    (sp)+,d0-d1    get rid of last 2 return addresses
  1908.     bra    do_cr        do a carriage return
  1909.  
  1910. .C    move.l    d5,d4        linmax=linhere
  1911.     bra    gimme3        show prompt,new line
  1912. do_not_print_func
  1913.     rts
  1914.     
  1915. convert_to_set_name
  1916.     lea    temp2buf(a5),a1
  1917.     move.b    d1,(a1)+
  1918.     addq.b    #1,d0
  1919.     move.b    d0,(a1)+
  1920.     cmp.b    #':',d0
  1921.     bne    not_func10
  1922.     move.b    #'1',-1(a1)
  1923.     move.b    #'0',(a1)+
  1924. not_func10
  1925.     clr.b    (a1)
  1926.     rts
  1927.  
  1928. search_sets
  1929. * uses temp2buf, EXIT: D0 ptr to the associated set. D1 pts to prior set
  1930. * RETURN D0=0 IF NOT FOUND.
  1931.     movem.l    d2-d4/a1-a2,-(sp)
  1932.     lea    temp2buf(a5),a1
  1933.     move.l    a1,d2
  1934.     lea    first_set_defn(a5),a2
  1935.     move.l    a2,d4        NOTE PRIOR SET 
  1936.     move.l    (a2),d3
  1937. search_next_set
  1938.     beq    .B
  1939.     move.l    d3,a2
  1940.     lea    set_name(a2),a2    A2=current set name
  1941.     move.l    d2,a1        A1=name to match
  1942.     bra.s    .C
  1943. .A    tst.b    d0
  1944.     beq.s    .B
  1945. .C    move.b    (a1)+,d0
  1946.     move.b    (a2)+,d1
  1947.     bsr    compD1D0nocase
  1948.     beq.s    .A
  1949.  
  1950.     move.l    d3,a2
  1951.     move.l    d3,d4
  1952.     move.l    (a2),d3
  1953.     bra    search_next_set
  1954. .B    move.l    d3,d0
  1955.     move.l    d4,d1
  1956.     
  1957.     movem.l    (sp)+,d2-d4/a1-a2
  1958.     rts
  1959.  
  1960.  
  1961. * DO SCRIPT FILE STUFF   ENTRY A0 -> input line
  1962. scr_in    movem.l    a0-a1/a6,-(sp)
  1963.     clr.b    break_flag(a5)
  1964.     move.l    4.w,a6
  1965.     moveq    #0,d0
  1966.     moveq    #0,d1
  1967.     bset    #SIGBREAKB_CTRL_D,d1
  1968.     jsr    _LVOSetSignal(a6)
  1969.     movem.l    (sp)+,a0-a1/a6
  1970.     btst    #SIGBREAKB_CTRL_D,d0    ;checks if CTRL_D pressed
  1971.     beq.s    .B
  1972.     lea    breaktx(pc),a1
  1973.     bsr    pr_string
  1974.     move.b    #1,break_flag(a5)
  1975.     bra.s    terminate_script
  1976. .B    move.l    scsize(a5),d1    ;read a line from the script file
  1977.     add.l    scaddr(a5),d1
  1978.     sub.l    scptr(a5),d1
  1979.     beq.s    terminate_script
  1980.     bpl.s    scr_in2
  1981. terminate_script
  1982.     bsr    kill_script
  1983.     move.l    errorstack(a5),sp
  1984.     bra    chorus
  1985.  
  1986. scr_in2    move.l    a0,a2
  1987.     moveq    #0,d0
  1988.     move.l    scptr(a5),a1
  1989.     cmp.b    #LF,(a1)
  1990.     beq.s    .B
  1991. .A    move.b    (a1)+,(a2)+
  1992.     addq.l    #1,d0
  1993.     cmp.b    #LF,(a1)
  1994.     bne.s    .A
  1995. .B    move.b    (a1)+,(a2)+    LF
  1996.     clr.b    (a2)        0
  1997.     move.l    a1,scptr(a5)
  1998.     btst    #FLdebug,Flags+3(a5)
  1999.     beq.s    .C
  2000.     clr.b    noreview_flag
  2001.     bsr    pr_prompt
  2002.     move.l    a0,a1
  2003.     bsr    pr_string
  2004. .C    rts
  2005.  
  2006. kill_script
  2007.     move.l    a0,-(sp)
  2008.     clr.b    scflag(a5)    clean up if no more lines left
  2009.     clr.b    if_flag(a5)    Make sure if structure ends
  2010.     clr.b    goto_flag(a5)    Make sure goto is terminated
  2011.     move.l    scaddr(a5),a1
  2012.     move.l    scsize(a5),d0
  2013.     bsr    givemem
  2014.     move.l    (sp)+,a0
  2015.     rts
  2016.  
  2017. ** SAME AS compare_strings EXCEPT
  2018. ** ALLOWS FOR A1 ENDING IN LF
  2019. lf_compare_strings
  2020.     movem.l    d0-d1/a0-a1,-(sp)
  2021.     bra.s    .A
  2022. .B    tst.b    d0
  2023.     beq.s    .C    RETURN EQ
  2024. .A    move.b    (a0)+,d0
  2025.     move.b    (a1)+,d1
  2026.     bsr    compD1D0nocase
  2027.     beq.s    .B    return NE
  2028.     tst.b    d0
  2029.     bne.s    .C
  2030.     cmp.b    #LF,d1
  2031. .C    movem.l    (sp)+,d0-d1/a0-a1
  2032.     rts
  2033.  
  2034.     
  2035. ** CASE INDEPENDENT STRING COMPARE. COMPARES (A0) TO (A1)
  2036. ** RETURN EQ IF SAME
  2037. compare_strings
  2038.     movem.l    d0-d1/a0-a1,-(sp)
  2039.     bra.s    .A
  2040. .B    tst.b    d0
  2041.     beq.s    .C    RETURN EQ
  2042. .A    move.b    (a0)+,d0
  2043.     move.b    (a1)+,d1
  2044.     bsr    compD1D0nocase
  2045.     beq.s    .B    return NE
  2046. .C    movem.l    (sp)+,d0-d1/a0-a1
  2047.     rts
  2048.  
  2049.     
  2050. * COPY STRING :copys null ending string from A0 to A1, Return with D0=length+1
  2051. cp_string    movem.l a0-a1,-(sp)
  2052.     moveq #0,d0
  2053. cp_str1    addq.l #1,d0
  2054.     move.b (a0)+,(a1)+
  2055.     bne.s cp_str1
  2056.     movem.l (sp)+,a0-a1
  2057.     rts
  2058.  
  2059. *Get line of text and seperate into up to 6 parameters    
  2060. get_line    addq.l    #1,count_line(a5)
  2061.     bsr    clr_parms
  2062.     lea    shelline(a5),a0
  2063.     tst.b    mult_comm_flag(a5) SKIP PROMPT IF SCRIPT OR MULT COMMANDS
  2064.     bne.s    .A
  2065.     tst.b    scflag(a5)
  2066.     bne.s    .B
  2067.     addq.b    #1,noreview_flag(a5)
  2068.     bsr    pr_prompt
  2069. .B    bsr    type_in    NOTE HISTORY STUFF ASSUMES SHELLINE HOLDS THE LINE
  2070.     clr.b    noreview_flag(a5)
  2071.     cmp.b    #';',(a0)        ;is 1st character a ';'
  2072.     beq.s    .C
  2073.     cmp.b    #'*',(a0)
  2074.     beq.s    .C
  2075.     cmp.b    #'#',(a0)
  2076.     bne.s    .A
  2077. .C    addq.l    #4,sp        ;kill return address
  2078.     bra    chorus        ;do next line if comment
  2079. .A    bsr    handle_mult_comms    MAYBE ALTER A0
  2080.     bsr    handle_command_alias
  2081.     bsr    handle_redirection
  2082.     btst    #FLdebug,Flags+3(a5)
  2083.     beq.s    gl16
  2084.     tst.b    scflag(a5)
  2085.     bne.s    gl16
  2086.     move.l    a0,-(sp)        TEST STUFF
  2087.     lea    pfeil(pc),a1
  2088.     bsr    pr_string
  2089.     move.l    a0,a1
  2090.     bsr    pr_string
  2091.     move.l    (sp)+,a0
  2092. gl16    lea    parm1(a5),a2 do 1st parm seperate to establish CLI residue
  2093.     bsr    get_parm
  2094.     move.l    a0,d7
  2095.     tst.l    d2
  2096.     beq    gl3            if no parms at all
  2097.     tst.b    goto_flag(a5)    CHECK IF IN GOTO SEARCH MODE
  2098.     beq.s    test_ifs
  2099.     move.l    a0,-(sp)
  2100.     lea    label_tx(pc),a0
  2101.     bsr    lf_compare_strings
  2102.     bne    skipline
  2103.     move.l    (sp)+,a0
  2104.  
  2105. * Script-IF handling
  2106. test_ifs    tst.b    if_flag(a5)    0 if if encountered earlier
  2107.     beq.s    no_ifs
  2108.     tst.b    if_condition(a5)    0 if condition TRUE
  2109.     beq    no_ifs
  2110. if_false    move.l    a0,-(sp)        push ptr to next
  2111.     lea    else_tx(pc),a0
  2112.     bsr    lf_compare_strings
  2113.     bne.s    try_endif
  2114.     not.b    if_condition(a5)    flip condition flag
  2115. skipline    movem.l    (sp)+,d0-d1    get rid of last plus return address
  2116.     bra    chorus
  2117. try_endif    lea    endif_tx(pc),a0
  2118.     bsr    lf_compare_strings
  2119.     bne.s    skipline
  2120.     clr.b    if_flag(a5)
  2121.     bra.s    skipline
  2122.  
  2123. no_ifs    move.l    a1,(a2)+    save address of parm1
  2124.  
  2125.     lea    CLIbuf(a5),a1
  2126. .C    move.b    (a0)+,d0    skip all preceding spaces
  2127.     cmp.b    #LF,d0
  2128.     beq    .D
  2129.     cmp.b    #" ",d0
  2130.     beq.s    .C
  2131. .B    move.b    d0,(a1)+
  2132.     move.b    (a0)+,d0    copy sudoCLIresidue out
  2133.     cmp.b    #LF,d0        only look for LF end
  2134.     bne.s    .B
  2135. .E    move.b    -(a1),d0    skip all ending spaces
  2136.     cmp.b    #" ",d0
  2137.     beq.s    .E
  2138.     addq.l    #1,a1
  2139. .D    clr.b    (a1)        null end the copy
  2140.     move.l    d7,a0
  2141.     lea    endofparms(a5),a4    establish end of parms block
  2142. gl4    bsr    get_parm        
  2143.     tst.l    d2
  2144.     beq.s    gl3
  2145.     move.l    a1,(a2)+
  2146.     cmp.l    a2,a4        get out if more than 25 parms
  2147.     bne.s    gl4
  2148.     clr.b    (a0)        make sure parm ends in 0
  2149. gl3    rts
  2150.  
  2151. endifz    clr.b    if_flag(a5)
  2152.     moveq    #RETURN_OK,d0
  2153.     rts
  2154. elsez    not.b    if_condition(a5)
  2155.     moveq    #RETURN_OK,d0
  2156.     rts
  2157.  
  2158. *************************
  2159. *        SKIP         *
  2160. *************************
  2161.  
  2162. skipz    move.l    parm2(a5),d1
  2163.     bne    test_gs
  2164. skip_err    lea    goto_error_tx(pc),a1
  2165.     bsr    pr_string
  2166.     moveq    #RETURN_ERROR,d0
  2167.     rts
  2168. test_gs    tst.b    scflag(a5)    CAN ONLY GOTO FROM WITHIN SCRIPT
  2169.     beq    skip_err
  2170.  
  2171.     move.l    d1,a0
  2172.     lea    dest_label(a5),a1
  2173. .B    move.b    (a0)+,(a1)+
  2174.     bne.s    .B
  2175.     move.l    scaddr(a5),scptr(a5)  RESET TO START OF SCRIPT
  2176.     move.b    #$ff,goto_flag(a5)
  2177.     clr.b    if_flag(a5)    MAKE SURE IF IS TERMINATED
  2178.     moveq    #RETURN_OK,d0
  2179.     rts
  2180.  
  2181. *************************
  2182. *    LABEL        *     DOES NOTHING IF NOT IN GOTO SEARCH MODE
  2183. *************************
  2184. labelz    tst.b    goto_flag(a5)
  2185.     bne.s    .A
  2186. .B    moveq    #RETURN_OK,D0
  2187.     RTS
  2188. .A    move.l    parm2(a5),d0
  2189.     beq.s    .B
  2190.     move.l    d0,a0
  2191.     lea    dest_label(a5),a1
  2192.     bsr    compare_strings
  2193.     bne    .B
  2194.     clr.b    goto_flag(a5)
  2195.     bra.s    .B
  2196.     
  2197.     
  2198. *ENTRY A0=shelline    ONLY HANDLES ALIASES OF FIRST KEYWORD.
  2199. handle_command_alias
  2200.     movem.l    d0-d2/a1-a4,-(sp)
  2201.     cmp.b    #LF,(a0)
  2202.     beq    hca_nothing_typed
  2203.     move.l    a0,a1
  2204.     lea    tempbuf(a5),a3
  2205.     move.b    #LF,(a3)
  2206.     clr.b    1(a3)    must be null end string
  2207.     lea    temp2buf(a5),a2    COPY PARM AT A0 TO SEARCH STR
  2208. .B    move.b    (a1)+,(a2)+
  2209.     cmp.b    #LF,(a1)
  2210.     beq.s    .D        hca_one_parm
  2211.     cmp.b    #$20,(a1)
  2212.     bne.s    .B
  2213. .D    move.b    (a1)+,(a3)+    COPY FROM SPACE ONWARDS to tempbuf
  2214.     bne.s    .D    WHOLE LINE ENDS IN NULL.
  2215. hca_one_parm
  2216.     clr.b    (a2)    null end search string
  2217.  
  2218. hca_find_it
  2219.     move.l    a0,-(sp)
  2220.     bsr    search_sets
  2221.     move.l    (sp)+,a0
  2222.     tst.l    d0
  2223.     beq    hca_nothing_typed
  2224.     move.l    d0,a2
  2225.  
  2226.     lea    set_defn(a2),a2    A2=set defn
  2227.     lea    tempbuf(a5),a3    A3=line after alias
  2228.     move.l    a0,a1        A1=shelline ptr
  2229.     moveq    #7,d0
  2230. .F    clr.l    -(sp)        push down eight times 0=no entry.
  2231.     dbra    d0,.F
  2232. .E    move.b    (a2)+,d0        handle %1...$1
  2233.     beq    not_much_of_an_alias
  2234.     cmp.b    #$20,d0        skip spaces
  2235.     beq.s    .E
  2236.     cmp.b    #'%',d0
  2237.     bne.s    no_extra_parms
  2238.     move.b    (a2)+,d0
  2239.     and.w    #$0007,d0        only allow %0 --> %7
  2240. .A    move.b    (a3)+,d1        find where the next param starts
  2241.     cmp.b    #LF,d1
  2242.     beq.s    .C        if no param then pt A3 to lf again
  2243.     cmp.b    #$20,d1
  2244.     beq.s    .A
  2245. .D    lsl.w    #2,d0        x 4
  2246.     move.l    a3,0(sp,d0.w)
  2247.     subq.l    #1,0(sp,d0.w)    put address of param on stack
  2248. .B    move.b    (a3)+,d1        get a3 to pt to next space
  2249.     cmp.b    #LF,d1
  2250.     beq    .C
  2251.     cmp.b    #$20,d1
  2252.     bne.s    .B
  2253. .C    lea    -1(a3),a3        a3 ts to space
  2254.     bra.s    .E        do for more params
  2255. get_next_character
  2256.     move.b    (a2)+,d0
  2257. no_extra_parms
  2258.     cmp.b    #'$',d0
  2259.     bne.s    .A
  2260.     move.b    (a2)+,d0        grab number after $
  2261.     beq.s    not_much_of_an_alias
  2262.     and.w    #$0007,d0
  2263.     lsl.w    #2,d0        x 4
  2264.     move.l    0(sp,d0.w),d1
  2265.     beq.s    get_next_character
  2266.     move.l    d1,a4
  2267. .B    move.b    (a4)+,(a1)+    copy param N
  2268.     cmp.b    #LF,(a4)
  2269.     beq.s    .C
  2270.     cmp.b    #$20,(a4)
  2271.     bne.s    .B
  2272. .C    bra.s    get_next_character
  2273. .A    move.b    d0,(a1)+        copy DEFN -> SHELLINE
  2274.     tst.b    d0
  2275.     bne.s    get_next_character
  2276.  
  2277.     lea    -1(a1),a1
  2278. not_much_of_an_alias
  2279.     lea    32(sp),sp        ** NOTE STACK CHANGE
  2280. .D    move.b    (a3)+,(a1)+    copy tempbuf onto end
  2281.     bne.s    .D
  2282.     clr.b    mult_comm_flag(a5)
  2283.     bsr    handle_mult_comms
  2284.     bsr    handle_command_alias
  2285.     clr.b    mult_comm_flag(a5)
  2286.     bsr    handle_mult_comms    put LF at end Allow for aliases with ;'s
  2287.     
  2288. hca_nothing_typed
  2289.     movem.l    (sp)+,d0-d2/a1-a4
  2290.     rts
  2291.  
  2292.  
  2293.     
  2294. clr_parms    movem.l    a0-a1,-(sp)
  2295.     lea    parm1(a5),a0
  2296.     lea    endofparms(a5),a1
  2297. clr_loop1    clr.l    (a0)+
  2298.     cmp.l    a0,a1
  2299.     bne.s    clr_loop1
  2300.     movem.l    (sp)+,a0-a1
  2301.     rts
  2302.  
  2303. * GET PARM line pted to by A0
  2304. * LINE MUST END IN LF THEN 0
  2305. * returns A1 pointing to the address where the parm starts
  2306. * puts a 0 over the space or lf where it ends .A0 pts to next bit on end
  2307. * return d2=0 if got all possible commands from line
  2308. get_parm    moveq    #$20,d2    D2=delimiter
  2309. get_parm1    move.l    a0,a1    ;make sure we can get the address before
  2310.     move.b    (a0)+,d1    ;skip spaces
  2311.     beq.s    last_parm2
  2312.     cmp.b    #$20,d1
  2313.     beq.s    get_parm1
  2314.     cmp.b    #$9,d1    skip tabs
  2315.     beq.s    get_parm1
  2316.     cmp.b    #LF,d1    ;handle idiots who type spaces at end of line
  2317.     beq.s    last_parm
  2318.     cmp.b    #'"',d1    ;handle double quotes
  2319.     bne.s    gp2
  2320.     addq.l    #1,a1
  2321.     moveq    #'"',d2    SET DELIMITER = "
  2322.     bra.s    gp2
  2323. gp4    addq.l    #1,a0    ;make sure pts to after quotes d1 is dummy
  2324. gp2    move.b    (a0)+,d1    ;a0 pts to after the space on exit
  2325.     cmp.b    #LF,d1
  2326.     beq.s    gp3
  2327.     cmp.b    #$5c,d1    allow for \" (nested quotes)
  2328.     beq.s    gp4
  2329.     cmp.b    d2,d1
  2330.     bne.s    gp2
  2331.     clr.b -1(a0)    ;make sure last byte is 0
  2332.     rts
  2333. last_parm    clr.b -1(a0)
  2334. last_parm2    moveq #0,d2    ;signify the end
  2335.         rts
  2336. gp3    lea -1(a0),a0 if ends in LF then dont null end, catch that next time
  2337.     rts
  2338.  
  2339. close_redirection
  2340.     move.l    stdin(a5),d0
  2341.     cmp.l    inhandle(a5),d0
  2342.     beq    cls_outred
  2343.     move.l    thistask(a5),a0
  2344.     move.l    pr_CIS(a0),d1
  2345.     move.l    d0,pr_CIS(a0)    restore old stdin
  2346.     move.l    d0,inhandle(a5)
  2347.     jsr    _LVOClose(a6)
  2348. cls_outred
  2349.     move.l    stdout(a5),d0
  2350.     cmp.l    outhandle(a5),d0
  2351.     beq    cls_nothing
  2352.     move.l    thistask(a5),a0
  2353.     move.l    pr_COS(a0),d1
  2354.     move.l    d0,pr_COS(a0)    restore old stdout
  2355.     move.l    d0,outhandle(a5)    
  2356.     jsr    _LVOClose(a6)
  2357.     tst.l    MPipePtr(a5)
  2358.     beq.s    cls_nothing
  2359.     movem.l    d2-d7/a2-a4,-(sp)
  2360.     bsr    raw_on
  2361.     sub.l    a3,a3
  2362.     bsr    viewbuffer
  2363.     movem.l    (sp)+,d2-d7/a2-a4
  2364.     clr.l    MPipePtr(a5)
  2365. cls_nothing
  2366.     rts
  2367.     
  2368. * entry A0 pts to shelline
  2369. handle_redirection
  2370.     movem.l    d0/a0-a3,-(sp)
  2371.     lea    tempbuf(a5),a2
  2372. redir_2    move.b    (a0)+,d0    CHECK FOR REDIRECTION CHARS < >
  2373.     cmp.b    #LF,d0
  2374.     bne.s    .C
  2375. .F    movem.l    (sp)+,d0/a0-a3
  2376.     rts
  2377. .C    cmp.b    #'"',d0    HANDLE QUOTES
  2378.     bne.s    .A
  2379. .B    move.b    (a0)+,d0
  2380.     cmp.b    #LF,d0
  2381.     beq    .F
  2382.     cmp.b    #'"',d0
  2383.     bne.s    .B
  2384. .A    cmp.b    #$20,d0
  2385.     bne.s    redir_2
  2386.     move.b    (a0),d0    TEST CHAR AFTER SPACE.
  2387.     cmp.b    #'>',d0
  2388.     beq.s    redir_out
  2389.     cmp.b    #'<',d0
  2390.     bne.s    redir_2
  2391. redir_in
  2392.     move.l    #MODE_OLDFILE,d2
  2393.     cmp.b    #">",1(a0)
  2394.     beq.s    redir_both
  2395.     bsr    redir_open
  2396.     bsr    ChngIn
  2397.     move.l    a3,a0
  2398.     bra    redir_2        KEEP SEARCHING
  2399. redir_both
  2400.     bsr    redir_open
  2401.     bsr    ChngIn
  2402.     bra.s    re_out2
  2403. redir_out
  2404.     cmp.b    #">",1(a0)
  2405.     beq.s    redir_append
  2406.     lea    -1(a0),a3        ALIGN WITH SPACE
  2407.     bsr    copy_redirector
  2408.     move.b    (a2),d0
  2409.     bset    #5,d0
  2410.     cmp.b    #"m",d0
  2411.     bne.s    re_out2
  2412.     tst.b    1(a2)
  2413.     bne.s    re_out2
  2414.     clr.b    (a2)    redir to MORE, send to nil:
  2415.     move.l    ReviewPtr(a5),MPipePtr(a5)
  2416. re_out2    move.l    #MODE_NEWFILE,d2
  2417.     bsr    redir_open2
  2418.     bsr    ChngOut
  2419.     move.l    a3,a0
  2420.     bra    redir_2
  2421. redir_append
  2422.     move.l    #MODE_READWRITE,d2
  2423.     bsr    redir_open
  2424.     bsr    ChngOut
  2425.     move.l    d0,d1
  2426.     moveq    #0,d2    set position
  2427.     moveq    #1,d3    set mode
  2428.     jsr    _LVOSeek(a6)
  2429.     move.l    a3,a0
  2430.     bra    redir_2
  2431.  
  2432. ChngIn    move.l    thistask(a5),a0
  2433.     move.l    d0,pr_CIS(a0)    MAKE STDIN DIFFERENT.
  2434.     move.l    d0,inhandle(a5)
  2435.     rts
  2436. ChngOut    move.l    thistask(a5),a0
  2437.     move.l    d0,pr_COS(a0)
  2438.     move.l    d0,outhandle(a5)
  2439.     rts
  2440.  
  2441. redir_open
  2442.     lea    -1(a0),a3        ALIGN WITH SPACE
  2443.     bsr    copy_redirector
  2444. redir_open2
  2445.     tst.b    (a2)
  2446.     bne.s    .B
  2447.     lea    connil(pc),a2
  2448. .B    btst    #FLdebug,Flags+3(a5)
  2449.     beq.s    .A
  2450.     lea    star(pc),a2
  2451. .A    move.l    a2,d1
  2452.     jsr    _LVOOpen(a6)
  2453.     tst.l    d0
  2454.     beq    DOSerr
  2455.     rts
  2456.     
  2457. ** ENTRY A0 pts redirection symbol. A2 pts to area to save redirection name
  2458. ** EXIT A2 area holds null end string and redirection name is deleted from
  2459. **      shelline
  2460. copy_redirector
  2461.     movem.l    a0-a2,-(sp)
  2462.     move.l    a0,a1    SAVE START OF REDIRECTION STRING
  2463.     move.b    (a0)+,d0    BUMP PAST '<' or '>'
  2464. cpred3    move.b    (a0)+,d0
  2465.     cmp.b    #$20,d0
  2466.     beq.s    cpredsp
  2467.     cmp.b    #LF,d0
  2468.     beq.s    cpredlf
  2469.     cmp.b    #'>',d0    HANDLE APPEND REDIRECTION PROPERLY
  2470.     beq.s    cpred3
  2471.     move.b    d0,(a2)+    COPY NEWSTDIN/OUT TO NONSTDIN/OUT
  2472.     bra.s    cpred3
  2473. cpredlf    lea    -1(a0),a0
  2474.     lea    -1(a1),a1
  2475. cpredsp    clr.b    (a2)+    A0 should point to after the space or lf
  2476.     lea    shelline+SHELLINE_SIZE(a5),a2
  2477.     move.l    a1,d0
  2478.     sub.l    a0,d0
  2479.     add.l    d0,next_comm_ptr(a5)    offset next_comm_ptr
  2480. cpred5    move.b    (a0)+,(a1)+    delete redirection string from shelline
  2481.     cmp.l    a0,a2
  2482.     bhi.s    cpred5
  2483.     movem.l    (sp)+,a0-a2
  2484.     rts
  2485.  
  2486. ** V1.14 multiple commands on command line. Delimit by ';'
  2487. * ENTRY A0 pts to shelline, EXIT A0 pts to start of next bit on line.
  2488. handle_mult_comms
  2489.     movem.l    d0/a1,-(sp)
  2490.     tst.b    mult_comm_flag(a5)
  2491.     beq.s    .A
  2492.     move.l    next_comm_ptr(a5),a0
  2493. .A    move.l    a0,a1
  2494. .B    move.b    (a1)+,d0
  2495.     cmp.b    #$5c,d0        is it \ ?
  2496.     beq.s    .E
  2497.     cmp.b    #'"',d0    ignore semi-colons between quotes
  2498.     bne.s    .C
  2499. .D    move.b    (a1)+,d0
  2500.     beq.s    endofline    END OF LINE IS NULL.
  2501.     cmp.b    #LF,d0
  2502.     beq.s    fndret
  2503.     cmp.b    #'"',d0
  2504.     bne.s    .D
  2505.     bra.s    .B
  2506. .E    move.b    (a1)+,d0
  2507.     bra.s    .F
  2508. .C    cmp.b    #';',d0
  2509.     beq    fndsemi
  2510. .F    cmp.b    #LF,d0
  2511.     bne.s    .B
  2512. fndret    tst.b    (a1)    IF NULL FOLLOWS LF THEN AT END OF LINE
  2513.     bne.s    fndsemi
  2514. endofline    clr.b    mult_comm_flag(a5)
  2515.     movem.l    (sp)+,d0/a1
  2516.     rts
  2517. fndsemi    move.b    #LF,-1(a1)    REPLACE ; or LF WITH LF
  2518.     move.l    a1,next_comm_ptr(a5)
  2519.     move.b    #1,mult_comm_flag(a5)
  2520.     movem.l    (sp)+,d0/a1
  2521.     rts
  2522.  
  2523. ******************************
  2524. * Iconify Shell        V2.3 *
  2525. WaitAppIcon
  2526.     movem.l    d2-d7/a2-a4,-(sp)
  2527.     clr.b    tempbuf(a5)
  2528.     cmp.w    #36,kickver(a5)
  2529.     blo    .G
  2530.     bsr    KillAppWin
  2531.     bsr    raw_off
  2532.     bsr    clkof2
  2533.     bsr    CloseWin
  2534.  
  2535.     tst.l    diskobj(a5)
  2536.     bne.s    .I
  2537.     bsr    OpenIconLib
  2538.     beq.s    .A
  2539.     moveq    #3,d0
  2540.     jsr    _LVOGetDefDiskObject(a6)
  2541.     move.l    d0,diskobj(a5)
  2542.     beq    .A
  2543. .I    bsr    OpenWBLib
  2544.     beq    .A
  2545.     moveq    #0,d0    opened workbench.library
  2546.     moveq    #0,d1
  2547.     move.l    app_name(a5),a0
  2548.     move.l    thistask(a5),a1
  2549.     lea    pr_MsgPort(a1),a1
  2550.     move.l    a1,d3
  2551.     sub.l    a2,a2
  2552.     move.l    diskobj(a5),a3
  2553.     sub.l    a4,a4
  2554.     jsr    _LVOAddAppIconA(a6)    add appicon
  2555.     move.l    d0,d2
  2556.     beq.s    .B
  2557.     move.l    4.w,a6
  2558. .C    move.l    d3,a0
  2559.     jsr    _LVOWaitPort(a6)    wait for one message
  2560.     bsr    GetAppIMsgs
  2561.     move.l    wbbase(a5),a6
  2562.     move.l    d2,a0
  2563.     jsr    _LVORemoveAppIcon(a6)    remove appicon
  2564. .B    bsr    GetAppIMsgs
  2565.  
  2566. .A    move.l    dosbase(a5),a6
  2567.     tst.b    openwin_flag(a5)    restore window
  2568.     beq.s    .G
  2569.     move.l    thistask(a5),a3
  2570.     move.l    CLIptr(a5),a2
  2571.     move.l    windowname(a5),d1
  2572.     clr.b    openwin_flag(a5)
  2573.     bsr    OpenWin
  2574.     beq    cloga
  2575.     jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  2576.     move.l    d0,outhandle(a5)
  2577.     move.l    d0,stdout(a5)
  2578.     jsr    _LVOInput(a6)
  2579.     move.l    d0,inhandle(a5)
  2580.     move.l    d0,stdin(a5)
  2581.     bsr    InitAppWin
  2582.     tst.b    memclk_flag(a5)
  2583.     beq.s    .G
  2584.     bsr    clkon
  2585. .G    movem.l    (sp)+,d2-d7/a2-a4
  2586.     lea    tempbuf(a5),a1
  2587.     tst.b    (a1)
  2588.     beq.s    .D
  2589.     bsr    print_def
  2590. .D    rts
  2591.  
  2592. GetAppIMsgs
  2593.     move.l    4.w,a6
  2594. .B    move.l    d3,a0
  2595.     jsr    _LVOGetMsg(a6)        get all messages
  2596.     tst.l    d0
  2597.     beq.s    .A
  2598.     move.l    d0,a2
  2599.     cmp.w    #8,am_Type(a2)
  2600.     bne.s    .B
  2601.     bsr    ProcessApp
  2602.     move.l    a2,a1
  2603.     jsr    _LVOReplyMsg(a6)    reply them
  2604.     bra.s    .B
  2605. .A    rts
  2606.  
  2607. ProcessApp    ;Message in a2
  2608.     move.l    a2,-(sp)
  2609.     move.l    am_NumArgs(a2),d0
  2610.     move.l    am_ArgList(a2),a0
  2611.     lea    tempbuf(a5),a2
  2612.     bra.s    .D
  2613. .E    move.l    (a0)+,d1    process all args
  2614.     beq.s    .C        get name from lock to dir
  2615.     movem.l    d0-d3/a0/a3/a6,-(sp)
  2616.     move.l    dosbase(a5),a6
  2617.     jsr    _LVODupLock(a6)
  2618.     move.l    a2,a0
  2619.     bsr    eval_full_path
  2620.     jsr    _LVOUnLock(a6)
  2621. .A    tst.b    (a2)+
  2622.     bne.s    .A
  2623.     subq.l    #1,a2
  2624.     cmp.b    #":",-1(a2)
  2625.     beq.s    .B
  2626.     move.b    #"/",(a2)+    /-end path
  2627. .B    movem.l    (sp)+,d0-d3/a0/a3/a6
  2628. .C    move.l    (a0)+,d1    get filename
  2629.     beq.s    .D
  2630.     move.l    d1,a1
  2631.     bsr    addstring
  2632.     move.b    #" ",(a2)+    space-end
  2633. .D    dbra    d0,.E
  2634.     clr.b    (a2)
  2635.     move.l    (sp)+,a2
  2636.     rts
  2637.  
  2638. ** evaluate entire name associated with lock in D0, store string in A0
  2639. ** Return D1 = last lock to unlock
  2640. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  2641.  
  2642. OpenIconLib
  2643.     move.l    iconbase(a5),d0
  2644.     bne.s    .A
  2645.     move.l    4.w,a6
  2646.     lea    iconname(pc),a1
  2647.     jsr    _LVOOldOpenLibrary(a6)    icon-library
  2648.     move.l    d0,iconbase(a5)
  2649. .A    move.l    d0,a6
  2650.     rts
  2651.  
  2652. OpenWBLib
  2653.     move.l    wbbase(a5),d0
  2654.     bne.s    .A
  2655.     move.l    4.w,a6
  2656.     lea    wbname(pc),a1
  2657.     jsr    _LVOOldOpenLibrary(a6)
  2658.     move.l    d0,wbbase(a5)
  2659. .A    move.l    d0,a6
  2660.     rts
  2661.  
  2662. **********************************************
  2663. * Create CLI-Interface-Structure    V2.0 *
  2664. CreateCLI
  2665.     move.l    thistask(a5),a3
  2666.     move.l    pr_WindowPtr(a3),window_old(a5)
  2667.     tst.b    CLIflag(a5)
  2668.     beq    CCli3
  2669.     clr.l    EntryA0(a5)        started from WB
  2670.     move.l    #64+$28+$50,d0
  2671.     move.l    #MEMF_CLEAR+1,d1    memory for CLI
  2672.     bsr    iwantmem
  2673.     moveq    #1,d1
  2674.     tst.l    d0
  2675.     beq    CCli2
  2676.     move.l    d0,a2
  2677.     lsr.l    #2,d0
  2678.     move.l    d0,pr_CLI(a3)
  2679.     move.l    dl_Root(a6),a0
  2680.     move.l    (a0),a0
  2681.     add.l    a0,a0
  2682.     add.l    a0,a0
  2683.     moveq    #0,d2
  2684.     move.l    (a0),d0
  2685.     subq.l    #1,d0
  2686. .C    addq.l    #1,d2
  2687.     addq.l    #4,a0
  2688.     tst.l    (a0)        look for free CLI-Number
  2689.     dbeq    d0,.C
  2690.     moveq    #2,d1
  2691.     tst.l    (a0)
  2692.     bne    CCli2
  2693.     lea    pr_MsgPort(a3),a1
  2694.     move.l    a1,(a0)
  2695.     move.l    d2,pr_TaskNum(a3)
  2696.     moveq    #10,d0
  2697.     move.l    d0,cli_FailLevel(a2)
  2698.     moveq    #-1,d0
  2699.     move.l    d0,cli_Interactive(a2)
  2700.     move.l    #1000,cli_DefaultStack(a2)    1000 LONGs
  2701.     move.l    pr_FileSystemTask(a3),filesys_old(a5)
  2702.     lea    64(a2),a0
  2703.     move.l    a0,d0
  2704.     lsr.l    #2,d0
  2705.     move.l    d0,cli_CommandFile(a2)
  2706.     lea    64+$28(a2),a0
  2707.     move.l    a0,d0
  2708.     lsr.l    #2,d0
  2709.     move.l    d0,cli_CommandName(a2)
  2710.     IFD    DEBUG
  2711.     tst.l    wb_msg(a5)
  2712.     beq    CreateCLI2    no WB-Msg -> CreateCLI2
  2713.     ENDC
  2714.     move.l    wb_msg(a5),a0
  2715.     tst.l    sm_Process(a0)
  2716.     beq    CreateCLI3    newcli/run -> CreateCLI3
  2717.     move.l    sm_ArgList(a0),a1
  2718.     moveq    #2,d0
  2719.     cmp.l    sm_NumArgs(a0),d0
  2720.     bhi.s    .H        Project ?
  2721.     addq.l    #8,a1
  2722. .H    move.l    (a1),a0        Lock on Current Dir
  2723.     moveq    #3,d1
  2724.     move.l    a0,d0
  2725.     beq    CCli2
  2726.     move.l    a0,d1
  2727.     move.l    dosbase(a5),a6
  2728.     jsr    _LVODupLock(a6)        WB wants to free its own lock
  2729.     bsr    SetCurrentDir
  2730.     move.l    4.w,a6
  2731.     lea    wbenchtx(pc),a1
  2732.     jsr    _LVOFindTask(a6)
  2733.     tst.l    d0
  2734.     beq.s    .E
  2735.     move.l    d0,a0
  2736.     tst.l    pr_CLI(a0)
  2737.     beq.s    .E
  2738.     move.l    dosbase(a5),a6
  2739.     bsr    CopyPaths    copy paths from workbench
  2740. .E    bsr    OpenIconLib
  2741.     moveq    #4,d1
  2742.     tst.l    d0
  2743.     beq    CCli2
  2744.     move.l    d0,a4
  2745.     move.l    wb_msg(a5),a0
  2746.     move.l    sm_ArgList(a0),a1
  2747.     moveq    #2,d0
  2748.     cmp.l    sm_NumArgs(a0),d0
  2749.     bhi.s    .I            Project ?
  2750.     move.l    12(a1),d0
  2751.     beq.s    .I
  2752.     move.l    d0,EntryA0(a5)        Name of Project as Script
  2753.     addq.l    #8,a1
  2754. .I    move.l    4(a1),a0        Name of Process
  2755.     jsr    _LVOGetDiskObject(a6)
  2756.     moveq    #5,d1
  2757.     move.l    d0,diskobj(a5)
  2758.     beq    CCli2
  2759.     move.l    d0,a0
  2760.     moveq    #0,d0
  2761.     bset    #31,d0        unset icon position
  2762.     move.l    d0,$3a(a0)    CurrentX
  2763.     move.l    d0,$3e(a0)    CurrentY
  2764.     move.b    #8,$30(a0)    Type=AppIcon
  2765.     move.l    do_ToolTypes(a0),d3    d3=ToolTypes
  2766.     move.l    d3,a0
  2767.     lea    xpostool(pc),a1
  2768.     jsr    _LVOFindToolType(a6)    Look for XPOS-ToolType
  2769.     tst.l    d0
  2770.     beq.s    .G
  2771.     move.l    d0,a1
  2772.     bsr    convert_ASCII_to_num
  2773.     beq.s    .G
  2774.     move.l    diskobj(a5),a0
  2775.     move.l    d0,$3a(a0)
  2776. .G    move.l    d3,a0
  2777.     lea    ypostool(pc),a1
  2778.     jsr    _LVOFindToolType(a6)    Look for YPOS-ToolType
  2779.     tst.l    d0
  2780.     beq.s    .J
  2781.     move.l    d0,a1
  2782.     bsr    convert_ASCII_to_num
  2783.     beq.s    .J
  2784.     move.l    diskobj(a5),a0
  2785.     move.l    d0,$3e(a0)
  2786. .J    move.l    d3,a0
  2787.     lea    nametool(pc),a1
  2788.     jsr    _LVOFindToolType(a6)    Look for ICONNAME-ToolType
  2789.     tst.l    d0
  2790.     beq.s    .K
  2791.     move.l    d0,app_name(a5)
  2792. .K    move.l    d3,a0
  2793.     lea    iconifytool(pc),a1
  2794.     jsr    _LVOFindToolType(a6)    Look for ICONIFY-ToolType
  2795.     tst.l    d0
  2796.     beq.s    .B
  2797.     bset    #FLappicon,Flags+3(a5)
  2798.     bsr    WaitAppIcon
  2799. .B    move.l    d3,a0
  2800.     lea    wintool(pc),a1
  2801.     jsr    _LVOFindToolType(a6)    Look for WINDOW-ToolType
  2802.     lea    conname(pc),a0
  2803.     tst.l    d0
  2804.     beq.s    .D
  2805.     move.l    d0,a0
  2806. .D    move.l    a0,d1
  2807.     move.l    dosbase(a5),a6
  2808.     bsr    OpenWin            Open Window
  2809.     beq    CCli2a
  2810.     move.l    d3,a0
  2811.     lea    scripttool(pc),a1
  2812.     move.l    a4,a6
  2813.     jsr    _LVOFindToolType(a6)    Look for SCRIPT-ToolType
  2814.     tst.l    d0
  2815.     beq.s    .F
  2816.     move.l    d0,EntryA0(a5)
  2817. .F    move.l    d3,a0
  2818.     lea    norawtool(pc),a1
  2819.     jsr    _LVOFindToolType(a6)    Look for NORAW-ToolType
  2820.     tst.l    d0
  2821.     beq.s    .A
  2822.     clr.l    ConsoleSwitch(a5)
  2823. .A    move.l    d3,a0
  2824.     lea    commandtool(pc),a1
  2825.     jsr    _LVOFindToolType(a6)    Look for COMMAND-ToolType
  2826.     move.l    d0,d2
  2827.     bsr    Com2Script
  2828.     bne.s    CCli2a
  2829. CCli1    move.l    dosbase(a5),a6
  2830.     moveq    #0,d0
  2831.     rts
  2832. CCli2    bsr    GuruIt
  2833. CCli2a    move.l    dosbase(a5),a6
  2834.     moveq    #-1,d0
  2835.     rts
  2836.  
  2837. CCli3    move.l    pr_COS(a3),outhandle(a5)    started from CLI
  2838.     move.l    pr_ConsoleTask(a3),ConsoleSwitch(a5)
  2839.     move.l    pr_CurrentDir(a3),d1
  2840.     bne.s    .D
  2841.     moveq    #-2,d2
  2842.     jsr    _LVOLock(a6)
  2843.     tst.l    d0
  2844.     beq    .D
  2845.     bsr    SetCurrentDir
  2846. .D    move.l    EntryA0(a5),d0    process CLI-Command-Line
  2847.     beq.s    CCli1
  2848.     clr.l    EntryA0(a5)
  2849.     move.l    d0,a0
  2850.     lea    parm2(a5),a2
  2851.     lea    endofparms(a5),a4    establish end of parms block
  2852. .A    bsr    get_parm        
  2853.     tst.l    d2
  2854.     beq.s    .B
  2855.     move.l    a1,(a2)+
  2856.     cmp.l    a2,a4        get out if more than 25 parms
  2857.     bne.s    .A
  2858.     clr.b    (a0)        make sure last parm ends in 0
  2859. .B    lea    parm2(a5),a1
  2860.     bsr.s    StartOpts
  2861.     bne.s    CCli2a
  2862.     tst.l    d3
  2863.     beq.s    .C
  2864.     clr.l    ConsoleSwitch(a5)
  2865. .C    tst.l    d1
  2866.     beq.s    CCli1
  2867.     move.l    thistask(a5),a3
  2868.     move.l    pr_CLI(a3),a2
  2869.     add.l    a2,a2
  2870.     add.l    a2,a2
  2871.     bsr    OpenWin
  2872.     tst.l    d0
  2873.     beq.s    CCli2a
  2874.     tst.l    d3
  2875.     beq    CCli1
  2876.     clr.l    ConsoleSwitch(a5)
  2877.     bra    CCli1
  2878.  
  2879. StartOpts        ;examine startup-options, parms in a1
  2880.     moveq    #0,d1
  2881.     moveq    #0,d2
  2882.     moveq    #0,d3
  2883. .A    move.l    (a1)+,d0    ;returns window in d1, script in EntryA0
  2884.     beq.s    Com2Script    ;and start-command in d2, d3>0 if egs
  2885.     move.l    d0,a0
  2886.     cmp.b    #"-",(a0)+
  2887.     bne.s    .H
  2888.     move.b    (a0)+,d0
  2889.     or.b    #$20,d0
  2890.     cmp.b    #"s",d0        -s for Script
  2891.     bne.s    .B
  2892.     move.l    a0,EntryA0(a5)
  2893.     bra.s    .A
  2894. .B    cmp.b    #"w",d0        -w for Window
  2895.     bne.s    .C
  2896.     move.l    a0,d1
  2897.     bra.s    .A
  2898. .C    cmp.b    #"c",d0        -c for Command
  2899.     bne.s    .D
  2900.     move.l    a0,d2
  2901.     bra.s    .A
  2902. .D    cmp.b    #"d",d0        -d for detach
  2903.     bne.s    .E
  2904.     clr.l    -4(a1)
  2905.     bsr    initialise_default
  2906.     bsr    newcliz
  2907.     moveq    #-1,d0
  2908.     rts        end it
  2909. .E    cmp.b    #"r",d0        -r for not Resident
  2910.     beq.s    .A
  2911.     cmp.b    #"n",d0        -n for Noraw
  2912.     bne.s    .H
  2913.     moveq    #1,d3
  2914.     bra.s    .A
  2915. .H    lea    useit(pc),a1
  2916.     bsr    pr_stringlf
  2917.     moveq    #-1,d0
  2918.     rts
  2919.  
  2920. Com2Script        ;Makes a command to script, d2=command
  2921.     move.l    d1,-(sp)    ;returns d0=0 for OK
  2922.     moveq    #1,d0
  2923.     tst.l    d2
  2924.     beq.s    .B
  2925.     lea    null(pc),a0
  2926.     move.l    a0,EntryA0(A5)
  2927.     move.l    d2,a0
  2928.     moveq    #0,d0
  2929. .A    addq.l    #1,d0
  2930.     tst.b    (a0)+
  2931.     bne.s    .A
  2932.     move.l    d0,scsize(a5)
  2933.     moveq    #1,d1
  2934.     bsr    iwantmem
  2935.     beq.s    .B
  2936.     move.l    d0,scaddr(a5)
  2937.     move.l    d0,scptr(a5)
  2938.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  2939.     move.l    d0,a1
  2940.     move.l    d2,a0
  2941. .C    move.b    (a0)+,(a1)+
  2942.     bne.s    .C
  2943.     move.b    #LF,-1(a1)
  2944.     moveq    #1,d0
  2945. .B    move.l    (sp)+,d1
  2946.     subq.l    #1,d0
  2947.     rts
  2948.  
  2949. SetCurrentDir    ;lock in d0
  2950.     move.l    d0,a0
  2951.     add.l    a0,a0
  2952.     add.l    a0,a0
  2953.     move.l    fl_Task(a0),pr_FileSystemTask(a3)
  2954.     move.l    d0,d1
  2955.     jsr    _LVOCurrentDir(a6)
  2956.     move.l    d0,cdir_old(a5)
  2957.     rts
  2958.  
  2959. * Open Window for both Input and Output, Name in d1 , a2,a3 *
  2960. OpenWin    move.l    dosbase(a5),a6
  2961.     moveq    #0,d0
  2962.     cmp.b    #1,openwin_flag(a5)
  2963.     beq    .C
  2964.     move.b    #1,openwin_flag(a5)
  2965.     move.l    pr_CIS(a3),OldCIS(a5)
  2966.     move.l    pr_COS(a3),OldCOS(a5)
  2967.     clr.l    pr_CIS(a3)        avoid freeing it
  2968.     clr.l    pr_COS(a3)
  2969.     move.l    pr_ConsoleTask(a3),OldCTask(a5)
  2970.     clr.l    ConsoleSwitch(a5)
  2971.     move.l    d1,a0
  2972.     move.l    a0,windowname(a5)
  2973.     tst.b    (a0)
  2974.     beq.s    .A            NIL:
  2975.     move.l    #MODE_NEWFILE,d2
  2976.     jsr    _LVOOpen(a6)        open output-Window
  2977.     moveq    #11,d1
  2978.     move.l    d0,pr_COS(a3)
  2979.     beq    .B
  2980.     move.l    d0,d1
  2981.     move.l    d0,cli_StandardOutput(a2)
  2982.     move.l    d0,cli_CurrentOutput(a2)
  2983.     lsl.l    #2,d0
  2984.     move.l    d0,a0
  2985.     move.l    fh_Type(a0),d0
  2986.     move.l    d0,pr_ConsoleTask(a3)
  2987.     move.l    d0,ConsoleSwitch(a5)
  2988.     jsr    _LVOIsInteractive(a6)
  2989.     moveq    #12,d1
  2990.     tst.l    d0
  2991.     beq.s    .B
  2992.     lea    star(pc),a0
  2993.     move.l    a0,d1
  2994.     move.l    #MODE_OLDFILE,d2
  2995.     jsr    _LVOOpen(a6)        open input-window
  2996.     moveq    #13,d1
  2997.     move.l    d0,pr_CIS(a3)
  2998.     beq    .B
  2999.     move.l    d0,cli_StandardInput(a2)
  3000.     move.l    d0,cli_CurrentInput(a2)
  3001. .A    moveq    #-1,d0
  3002.     rts            d0<>0 if OK
  3003. .C    moveq    #10,d1
  3004. .B    bsr    GuruIt        d0=0 on error
  3005.     rts
  3006.  
  3007. CloseWin
  3008.     move.l    thistask(a5),a3
  3009.     tst.b    openwin_flag(a5)
  3010.     beq.s    .G
  3011.     move.l    pr_CIS(a3),d1
  3012.     beq.s    .C
  3013.     jsr    _LVOClose(a6)    close input-window
  3014. .C    move.l    pr_COS(a3),d1
  3015.     beq.s    .D
  3016.     jsr    _LVOClose(a6)    close output-window
  3017. .D    move.l    OldCIS(a5),d0
  3018.     move.l    d0,pr_CIS(a3)
  3019.     move.l    OldCOS(a5),d1
  3020.     move.l    d1,pr_COS(a3)
  3021.     move.l    OldCTask(a5),pr_ConsoleTask(a3)
  3022.     tst.l    pr_CLI(a3)
  3023.     beq.s    .G
  3024.     move.l    pr_CLI(a3),a2
  3025.     add.l    a2,a2
  3026.     add.l    a2,a2
  3027.     move.l    d0,cli_StandardInput(a2)
  3028.     move.l    d0,cli_CurrentInput(a2)
  3029.     move.l    d1,cli_StandardOutput(a2)
  3030.     move.l    d1,cli_CurrentOutput(a2)
  3031. .G    rts
  3032.  
  3033. * Create CLI-Interface-Structure without WB-Message    V2.0 *
  3034.     IFD    DEBUG
  3035. CreateCLI2
  3036.     lea    conname(pc),a0
  3037.     move.l    a0,d1
  3038.     bsr    OpenWin
  3039.     beq.s    .B
  3040.     lea    ramdisk(pc),a0
  3041.     move.l    a0,d1
  3042.     moveq    #-2,d2
  3043.     jsr    _LVOLock(a6)
  3044.     tst.l    d0
  3045.     beq    .B
  3046.     bsr    SetCurrentDir
  3047.     moveq    #0,d0
  3048.     rts
  3049. .B    moveq    #-1,d0
  3050.     rts
  3051.  
  3052. ramdisk    dc.b    "RAM:",0
  3053.     even
  3054.     ENDC
  3055.  
  3056. * Create CLI-Interface-Structure with special message    V2.0 *
  3057. *    a3:Process    a2:CLI_Struct    *
  3058. *sm_NumArgs:    General Memory Block
  3059. *sm_ToolWindow:    Current Dir
  3060. CreateCLI3
  3061.     move.b    #1,WBflag(a5)    not started from WB
  3062.     move.l    sm_NumArgs(a0),a4    wb_msg in a0
  3063.     move.l    sm_ToolWindow(a0),d1
  3064.     jsr    _LVODupLock(a6)        COPY CD
  3065.     moveq    #15,d1
  3066.     tst.l    d0
  3067.     beq    cce3
  3068.     bsr    SetCurrentDir
  3069.     move.l    outhandle(a4),outhandle(a5)    PROCESS PARMS
  3070.     lea    parm2(a4),a1
  3071.     bsr    StartOpts
  3072.     clr.l    outhandle(a5)
  3073.     tst.l    d0
  3074.     bne    cce2
  3075.     move.l    thistask(a4),a0        OPEN WINDOW
  3076.     move.l    pr_ConsoleTask(a0),pr_ConsoleTask(a3)
  3077.     lea    conname(pc),a0
  3078.     tst.l    d1
  3079.     bne.s    .H
  3080.     move.l    a0,d1
  3081. .H    bsr    OpenWin
  3082.     beq    cce2
  3083.     tst.l    d3
  3084.     beq.s    .B
  3085.     clr.l    ConsoleSwitch(a5)
  3086. .B    move.l    thistask(a4),a0            COPY SEARCH PATHS
  3087.     bsr    CopyPaths
  3088.     lea    prompt_args(a4),a0    COPY PROMPT
  3089.     lea    prompt_args(a5),a1
  3090. .G    move.b    (a0)+,(a1)+
  3091.     bne.s    .G
  3092.     lea    now(a4),a0        COPY HISTORY
  3093.     lea    now(a5),a1
  3094.     move.w    #HISTORY_SIZE+12-1,d0
  3095. .D    move.b    (a0)+,(a1)+
  3096.     dbra    d0,.D
  3097.     move.l    CLIptr(a4),a0
  3098.     move.l    cli_FailLevel(a0),cli_FailLevel(a2)
  3099.     move.l    Flags(a4),Flags(a5)
  3100.     moveq    #ctrl_inite-ctrl_init-1,d0    COPY CTRL-CODES
  3101.     lea    ctrl_codes(a4),a0
  3102.     lea    ctrl_codes(a5),a1
  3103. .E    move.b    (a0)+,(a1)+
  3104.     dbra    d0,.E
  3105.     lea    ignoreit(a4),a0
  3106.     lea    ignoreit(a5),a1
  3107. .F    move.b    (a0)+,(a1)+
  3108.     bne    .F
  3109. ccs3    movem.l    a2-a4,-(sp)    COPY ALL ALIASES
  3110.     moveq    #0,d3        Link Pointer
  3111.     move.l    first_set_defn(a4),d0    old aliases
  3112.     beq    .A
  3113. .B    move.l    d0,a3
  3114.     move.l    set_size(a3),d0
  3115.     move.l    d0,d2
  3116.     moveq    #1,d1
  3117.     bsr    iwantmem    get mem for set
  3118.     beq.s    .A
  3119.     move.l    d0,a2
  3120.     move.l    a3,a0        copy whole set
  3121.     move.l    a2,a1
  3122.     move.l    d2,d1
  3123.     subq.l    #1,d2
  3124. .C    move.b    (a0)+,(a1)+
  3125.     dbra    d2,.C
  3126.     move.l    d1,set_size(a2)    init set
  3127.     move.l    d3,(a2)
  3128.     move.l    a2,d3
  3129.     move.l    (a3),d0        check next set address
  3130.     bne    .B
  3131. .A    move.l    d3,first_set_defn(a5)
  3132.     move.l    ReviewSize(a4),d0    CREATE REVIEW-BUFFER
  3133.     beq.s    .D
  3134.     bsr    MakeReview
  3135. .D    movem.l    (sp)+,a2-a4
  3136.     move.l    EntryA0(a5),d0        SCRIPT GIVEN ?
  3137.     beq.s    .H
  3138.     move.l    d0,a0
  3139.     lea    prompt_string(a5),a1    there is enough place
  3140.     move.l    a1,EntryA0(a5)
  3141. .F    move.b    (a0)+,(a1)+    Copy Script-Parm
  3142.     bne.s    .F
  3143. .H    move.l    4.w,a6
  3144.     move.l    wb_msg(a5),a1
  3145.     jsr    _LVOReplyMsg(a6)
  3146.     clr.l    wb_msg(a5)
  3147.     move.l    dosbase(a5),a6
  3148.     moveq    #0,d0
  3149.     rts
  3150. cce3    bsr    GuruIt
  3151. cce2    moveq    #-1,d0
  3152.     rts
  3153.  
  3154.  
  3155. * Remove CLI-Interface-Structure    V2.0 *
  3156. RemoveCLI
  3157.     move.l    thistask(a5),a3
  3158.     move.l    window_old(a5),pr_WindowPtr(a3)
  3159.     move.l    old_homedir(a5),d0
  3160.     beq.s    .B
  3161.     move.l    d0,pr_HomeDir(a3)
  3162. .B    move.l    cdback(a5),d1
  3163.     beq.s    .H
  3164.     jsr    _LVOUnLock(a6)
  3165.  
  3166. .H    bsr    clkoff
  3167.     bsr    CloseWin
  3168.     move.l    diskobj(a5),d0
  3169.     beq.s    .F
  3170.     move.l    d0,a0
  3171.     move.l    iconbase(a5),a6
  3172.     jsr    _LVOFreeDiskObject(a6)
  3173. .F    move.l    4.w,a6
  3174.     move.l    iconbase(a5),d0
  3175.     beq.s    .A
  3176.     move.l    d0,a1
  3177.     jsr    _LVOCloseLibrary(a6)
  3178. .A    move.l    wbbase(a5),d0
  3179.     beq.s    .I
  3180.     move.l    d0,a1
  3181.     jsr    _LVOCloseLibrary(a6)
  3182. .I    move.l    dosbase(a5),a6
  3183.     move.l    pr_CLI(a3),d0
  3184.     beq    remend
  3185.     lsl.l    #2,d0
  3186.     move.l    d0,a2
  3187.     moveq    #10,d0
  3188.     move.l    d0,cli_FailLevel(a2)
  3189.     move.l    old_setname(a5),d0
  3190.     beq.s    remcli
  3191.     move.l    d0,cli_SetName(a2)
  3192.     lsl.l    #2,d0
  3193.     move.l    d0,a1
  3194.     lea    CD_string(a5),a0
  3195. .E    move.b    (a0)+,(a1)+    copy current dir name
  3196.     bne.s    .E
  3197.     move.l    old_prompt(a5),cli_Prompt(a2)
  3198.  
  3199. remcli    tst.b    CLIflag(a5)
  3200.     beq.s    remend
  3201.     clr.l    pr_CLI(a3)    clear CLI-Pointer
  3202.     move.l    pr_TaskNum(a3),d0
  3203.     beq.s    .E
  3204.     lsl.l    #2,d0
  3205.     move.l    dl_Root(a6),a0
  3206.     move.l    (a0),a0
  3207.     add.l    a0,a0
  3208.     add.l    a0,a0
  3209.     add.l    d0,a0
  3210.     clr.l    (a0)        free task-number
  3211.     clr.l    pr_TaskNum(a3)
  3212. .E    lea    cli_CommandDir(a2),a4
  3213.     bsr    DeletePaths    free search paths
  3214.     move.l    cdir_old(a5),d1
  3215.     jsr    _LVOCurrentDir(a6)
  3216.     move.l    d0,d1
  3217.     beq.s    .B
  3218.     jsr    _LVOUnLock(a6)    free current dir
  3219. .B    move.l    filesys_old(a5),pr_FileSystemTask(a3)
  3220.     clr.l    pr_Result2(a3)
  3221.     move.l    #64+$28+$50,d0
  3222.     move.l    a2,a1
  3223.     bsr    givemem        free memory of CLI
  3224. remend    move.l    dosbase(a5),a6
  3225.     rts
  3226.  
  3227. GuruIt    ;get errornumber in d1 and display a recoverable alert
  3228.     movem.l    d0-d1/a0-a1/a6,-(sp)
  3229.     lea    tempbuf(a5),a0
  3230.     move.l    a0,a1
  3231.     clr.b    (a1)+
  3232.     move.b    #250,(a1)+
  3233.     move.b    #15,(a1)+
  3234.     move.l    d1,d0
  3235.     bsr    qpr10
  3236.     clr.b    (a1)+
  3237.     clr.b    (a1)+
  3238.     move.l    intuibase(a5),a6
  3239.     moveq    #0,d0
  3240.     moveq    #35,d1
  3241.     jsr    _LVODisplayAlert(a6)
  3242.     movem.l    (sp)+,d0-d1/a0-a1/a6
  3243.     rts
  3244.  
  3245. *CHECK WHETHER THERE IS ENOUGH STACK FREE    V2.0 *
  3246. ;d0=requested stacksize
  3247. stacktest movem.l    d0-d1/a0-a1,-(sp)
  3248.     move.l    topstack(a5),a0
  3249.     sub.l    sp,a0
  3250.     move.l    a0,d1
  3251.     add.l    d0,d1
  3252.     add.l    #1600,d1    ;allow some bytes for DOS
  3253.     cmp.l    stacksize(a5),d1
  3254.     blo.s    .A
  3255.     lea    stack_tx(pc),a1
  3256.     bsr    pr_stringlf
  3257.     moveq    #-1,d0
  3258.     bra.s    .B
  3259. .A    moveq    #0,d0
  3260. .B    movem.l    (sp)+,d0-d1/a0-a1
  3261.     rts
  3262.  
  3263. too_less_args
  3264.     cmp.w    #36,kickver(a5)
  3265.     blo.s    .A
  3266.     movem.l    a0-a1,-(sp)
  3267.     moveq    #116,d0
  3268.     bsr    pr_DOSerr
  3269.     movem.l    (sp)+,a0-a1
  3270.     bra.s    .B
  3271. .A    lea    less_args_tx(pc),a1
  3272.     bsr    pr_stringlf
  3273. .B    move.l    #RETURN_BAD,d0
  3274.     rts
  3275.  
  3276. *SendPacket-Error-Tester
  3277. PKTerr    tst.l    sp_res1(a5)
  3278.     bne    .A
  3279.     move.l    sp_res2(a5),d0
  3280.     bra.s    pr_galactic
  3281. .A    rts
  3282. *DOSERRor but Unlock first using D7 as the lock
  3283. DOSerrUL    move.l d7,d1        ;Assume D7=lock
  3284.     beq.s    DOSerr
  3285.     move.l    thistask(a5),a2
  3286.     move.l    pr_Result2(a2),d2
  3287.     jsr    _LVOUnLock(a6)
  3288.     move.l    d2,pr_Result2(a2)
  3289. *DOSERRor handler D0=0 on entry
  3290. DOSerr    jsr    _LVOIoErr(a6)
  3291.     cmp.l    #232,d0
  3292.     bne.s    pr_galactic
  3293.     moveq    #0,d0
  3294.     rts            ;Return if ERROR_NO_MORE_ENTRIES
  3295. pr_galactic
  3296.     bsr.s    pr_DOSerr    ;entry for dospacket
  3297. galactic    move.l    errorstack(a5),sp    ;restore stack
  3298.     moveq    #RETURN_BAD,d0
  3299.     bra    chkfail        ;reenter shell loop
  3300.  
  3301. maybeDOSerr    ;checks if d0=0, then prints DOSerr
  3302.     move.l    d0,-(sp)
  3303.     bne.s    .A
  3304.     jsr    _LVOIoErr(a6)
  3305.     bsr    pr_DOSerr        error occured
  3306. .A    move.l    (sp)+,d0
  3307.     rts
  3308.  
  3309. * ENTRY D0=dos error number
  3310. pr_DOSerr
  3311.     cmp.w    #36,kickver(a5)
  3312.     blo.s    .E
  3313.     movem.l    d0-d4/a2,-(sp)
  3314.     move.l    d0,d1
  3315.     beq.s    .F
  3316.     lea    NewPrintBuffer(a5),a2
  3317.     lea    farb2(pc),a1
  3318.     bsr    addstring
  3319.     move.l    a2,d3
  3320.     moveq    #110,d4
  3321.     move.l    parm1(a5),d2
  3322.     jsr    _LVOFault(a6)
  3323.     lea    NewPrintBuffer(a5),a1
  3324.     bsr    pr_error
  3325.     lea    farb1(pc),a1
  3326.     bsr    pr_error
  3327.     lea    lf(pc),a1
  3328.     bsr    pr_error
  3329. .F    movem.l    (sp)+,d0-d4/a2
  3330.     rts
  3331. .E    lea    doserrtx(pc),a1
  3332.     bsr    pr_error
  3333.     lea    doserror_text(pc),a1    v1.21 handle textual errors
  3334.     bra.s    .C
  3335. .B    tst.b    (a1)+
  3336.     bne.s    .B
  3337. .C    move.b    (a1)+,d1
  3338.     beq.s    .A
  3339.     cmp.b    d1,d0
  3340.     bne.s    .B
  3341.     bsr    pr_error
  3342. .A    bsr    print10
  3343.     lea    lf(pc),a1
  3344.     bsr    pr_error
  3345. .D    rts
  3346.     
  3347. * fix up parameters that exist or not
  3348. fixpam32    move.l parm3(a5),d0
  3349.     move.l    d0,a1
  3350.     bne.s    fixpam2
  3351.     lea    null(pc),a1
  3352.     move.l    a1,parm3(a5)
  3353. fixpam2    move.l    parm2(a5),d0
  3354.     move.l    d0,a0
  3355.     bne.s    fxpam
  3356.     lea    null(pc),a0
  3357.     move.l    a0,parm2(a5)
  3358. fxpam    rts
  3359.     
  3360. *************************
  3361. *    RENAME        *
  3362. *************************
  3363. renamez    bsr    fixpam32
  3364. ;DON'T PUT ANYTHING HERE
  3365.     * A0-> oldname  A1-> newname
  3366. rename    move.l    a0,d1
  3367.     move.l    a1,d2
  3368.     jsr    _LVORename(a6)
  3369.     tst.l    d0
  3370.     beq    DOSerr
  3371.     moveq    #RETURN_OK,d0
  3372.     rts
  3373.  
  3374. *************************
  3375. *    MAKEDIR        *
  3376. *************************
  3377. makedirz    lea    parm2(a5),a4
  3378. .A    move.l    (a4)+,d1
  3379.     beq.s    .B
  3380.     bsr.s    mkdir
  3381.     bra.s    .A
  3382. .B    moveq    #RETURN_OK,d0
  3383.     rts
  3384.     
  3385. *MAKEDIR D1-> directory name
  3386. mkdir    jsr    _LVOCreateDir(a6)
  3387.     tst.l    d0
  3388.     beq    DOSerr
  3389.     move.l    d0,d1
  3390.     jsr    _LVOUnLock(a6)
  3391. *    moveq    #0,d0
  3392.     rts
  3393.  
  3394. *************************
  3395. *    PROMPT        *
  3396. *************************
  3397. promptz    tst.l    parm2(a5)
  3398.     beq.s    .B
  3399.     bsr    echoz
  3400.     bsr    pr_lf
  3401.     move.l    parm2(a5),a0
  3402.     lea    prompt_args(a5),a2
  3403.     lea    1(a2),a1
  3404.     moveq    #-1,d0
  3405. .A    addq.b    #1,d0
  3406.     move.b    (a0)+,(a1)+
  3407.     bne.s    .A
  3408. .C    move.b    d0,(a2)
  3409.     MOVEQ    #RETURN_OK,D0
  3410.     rts
  3411. .B    lea    prompt_args+1(a5),a1
  3412.     bsr    pr_stringlf
  3413.     moveq    #RETURN_OK,d0
  3414.     rts
  3415.     
  3416. **************    
  3417. compose_prompt
  3418.     lea    prompt_string(a5),a1
  3419.     move.l    a1,prompt_cr(a5)
  3420.     lea    farb3(pc),a0
  3421. .C    move.b    (a0)+,(a1)+    copy highlight colour
  3422.     bne.s    .C
  3423.     move.b    #15,-1(a1)    no-confuse-char
  3424.     lea    prompt_args+1(a5),a0
  3425. cpro3    move.b    (a0)+,d0
  3426.     beq    composer3
  3427.     cmp.b    #$5c,d0 ;\
  3428.     bne.s    .A
  3429.     move.b    (a0)+,d0
  3430.     bra    composer2
  3431. .A    cmp.b    #'%',d0
  3432.     bne    composer2
  3433.     move.b    (a0)+,d0
  3434.     bset    #5,d0
  3435.     cmp.b    #'p',d0        check if %p
  3436.     bne.s    try_halfcd
  3437.     lea    CD_string+1(a5),a2
  3438. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  3439.     bne.s    .B
  3440.     lea    -1(a1),a1
  3441.     bra    cpro3
  3442. try_halfcd
  3443.     cmp.b    #'s',d0        check if %s
  3444.     bne.s    try_line_num
  3445.     lea    CD_string+1(a5),a2
  3446.     move.l    a2,d1
  3447. .A    tst.b    (a2)+
  3448.     bne.s    .A
  3449.     subq.l    #2,a2
  3450.     bra.s    .D
  3451. .C    move.b    -(a2),d0
  3452. .D    cmp.l    a2,d1
  3453.     bhi.s    .E
  3454.     cmp.b    #"/",d0
  3455.     beq.s    .E
  3456.     cmp.b    #":",d0
  3457.     bne.s    .C
  3458. .E    addq.l    #1,a2
  3459. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  3460.     bne.s    .B
  3461.     lea    -1(a1),a1
  3462.     bra    cpro3
  3463. try_line_num
  3464.     cmp.b    #'l',d0        check if %l
  3465.     bne.s    try_oldcmd
  3466.     move.l    count_line(a5),d0
  3467.     moveq    #0,d1
  3468.     move.l    a1,a2
  3469.     bsr    qdecpr        insert current line number
  3470.     move.l    a2,a1
  3471.     bra    cpro3
  3472. try_oldcmd
  3473.     cmp.b    #'c',d0        check if %c
  3474.     bne.s    try_task_num
  3475.     lea    shelline(a5),a2
  3476. .B    move.b    (a2)+,(a1)+
  3477.     bne.s    .B
  3478.     lea    -1(a1),a1
  3479.     bra    cpro3
  3480. try_task_num
  3481.     cmp.b    #'n',d0        check if %n
  3482.     bne.s    composer2
  3483.     move.l    thistask(a5),a2
  3484.     move.l    pr_TaskNum(a2),d0
  3485.     add.b    #$30,d0
  3486. composer2    move.b    d0,(a1)+
  3487.     cmp.b    #LF,d0
  3488.     bne.s    .A
  3489.     move.l    a1,prompt_cr(a5)
  3490. .A    bra    cpro3
  3491. composer3    lea    farb1(pc),a0
  3492. .A    move.b    (a0)+,(a1)+
  3493.     bne.s    .A
  3494.     rts
  3495.  
  3496.     
  3497. *FILL FIB WITH EXAMINE A0-> directory name ,D7=filelock on return
  3498. fibexam    move.l    a0,-(sp)
  3499.     moveq    #ACCESS_READ,d2
  3500.     move.l a0,d1
  3501.     jsr    _LVOLock(a6)
  3502.     move.l    d0,d7
  3503.     beq    DOSerr
  3504.     bsr    fibexam2
  3505.     move.l    (sp)+,a0
  3506.     rts
  3507. fibexam2
  3508.     move.l    d0,d1
  3509.     move.l    a5,d2
  3510.     jsr    _LVOExamine(a6)
  3511.     tst.l    d0
  3512.     beq    DOSerrUL
  3513.     rts
  3514.  
  3515. *****************
  3516. *    CD    *
  3517. *****************
  3518. cdz    tst.l    parm2(a5)
  3519.     beq    querycd
  3520.     move.l    parm2(a5),a0
  3521. *CHANGE DIRECTORY A0-> new current directory
  3522.     bsr    fibexam
  3523.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  3524.     bpl.s    .A
  3525.     lea    cderrtx(pc),a1
  3526.     bsr    pr_string
  3527.     move.l    d7,d1
  3528.     jsr    _LVOUnLock(a6)
  3529.     moveq    #RETURN_ERROR,d0
  3530.     rts
  3531. .A    move.l    d7,d1
  3532. chdir    move.l    d1,a0
  3533.     add.l    a0,a0
  3534.     add.l    a0,a0
  3535.     move.l    thistask(a5),a1
  3536.     move.l    fl_Task(a0),pr_FileSystemTask(a1)
  3537.     jsr    _LVOCurrentDir(a6)
  3538.     move.l    cdback(a5),d1
  3539.     move.l    d0,cdback(a5)    remember old directory
  3540.     jsr    _LVOUnLock(a6)    unlock the old directory
  3541.     bsr    eval_CD        update cd string
  3542.     moveq    #RETURN_OK,d0
  3543.     rts
  3544.     
  3545. querycd    bsr    eval_CD
  3546.     lea    CD_string+1(a5),a1
  3547.     bsr    pr_stringlf
  3548.     moveq    #RETURN_OK,d0
  3549.     rts
  3550.  
  3551.  
  3552. ** Evaluate entire name of current directory and put in CD_string
  3553. eval_CD    clr.b    CD_string+1(a5)
  3554.     lea    null(pc),a0
  3555.     move.l    a0,d1
  3556.     moveq    #ACCESS_READ,d2
  3557.     jsr    _LVOLock(a6)
  3558.     tst.l    d0
  3559.     beq.s    .A
  3560.     move.l    d0,a0
  3561.     add.l    a0,a0
  3562.     add.l    a0,a0
  3563.     move.l    fl_Key(a0),cd_block(a5)
  3564.     move.l    fl_Volume(a0),cd_volnode(a5)
  3565.     lea    CD_string+1(a5),a0
  3566.     bsr    eval_full_path
  3567.     jsr    _LVOUnLock(a6)
  3568. .A    moveq    #-1,d0
  3569.     lea    CD_string(a5),a0
  3570.     lea    1(a0),a1
  3571. .B    addq.b    #1,d0
  3572.     tst.b    (a1)+
  3573.     bne.s    .B
  3574.     move.b    d0,(a0)
  3575.     rts
  3576.     
  3577. ** evaluate entire name associated with lock in D0, store string in A0
  3578. ** Return D1 = last lock to unlock
  3579. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  3580. eval_full_path
  3581.     move.b    #"?",(a0)
  3582.     clr.b    1(a0)
  3583.     move.l    d0,d1
  3584.     beq.s    .C
  3585.     lsl.l    #2,d0
  3586.     move.l    d0,a1
  3587.     moveq    #ACCESS_READ,d0
  3588.     cmp.l    fl_Access(a1),d0    only eval read locks
  3589.     bne.s    .B
  3590. .C    cmp.w    #36,kickver(a5)
  3591.     blo.s    .A
  3592.     move.l    d1,a3
  3593.     move.l    a0,d2
  3594.     moveq    #78,d3
  3595.     jsr    _LVONameFromLock(a6)
  3596.     move.l    a3,d1
  3597. .B    rts
  3598. .A    lea    -88(sp),sp
  3599.     move.l    a0,4(sp)        save address of string
  3600.     move.l    d1,(sp)        save original lock on stack
  3601.     move.l    a5,d2
  3602.     jsr    _LVOExamine(a6)
  3603.     move.l    4(sp),a1
  3604.     lea    fib_FileName(a5),a0
  3605. evx1    move.b    (a0)+,(a1)+    COPY FILENAME TO deststring
  3606.     bne.s    evx1
  3607.     lea    -1(a1),a3
  3608. evcd2    move.l    (sp),d1        get lock
  3609.     jsr    _LVOParentDir(a6)
  3610.     tst.l    d0
  3611.     beq.s    root_found
  3612.     move.l    (sp),d1
  3613.     move.l    d0,(sp)
  3614.     jsr    _LVOUnLock(a6)    unlock last
  3615.     move.l    (sp),d1
  3616.     move.l    a5,d2
  3617.     jsr    _LVOExamine(a6)
  3618.     lea    fib_FileName(a5),a0
  3619.     lea    8(sp),a1
  3620. evx2    move.b    (a0)+,(a1)+    stackbuf = filename
  3621.     bne.s    evx2
  3622.     move.b    #'/',-1(a1)
  3623.     move.l    4(sp),a0
  3624. evx3    move.b    (a0)+,(a1)+    stackbuf = filename/CD_string
  3625.     bne.s    evx3
  3626.     move.l    4(sp),a1
  3627.     lea    8(sp),a0
  3628. evx4    move.b    (a0)+,d0
  3629.     move.b    d0,(a1)+
  3630.     cmp.b    #'/',d0
  3631.     bne.s    evx4
  3632.     lea    -1(a1),a3
  3633. evx5    move.b    (a0)+,(a1)+    dest string = stackbuf
  3634.     bne.s    evx5
  3635.     bra    evcd2
  3636. root_found
  3637.     move.l    (sp),d1
  3638.     tst.b    (a3)
  3639.     bne.s    root2
  3640.     clr.b    1(a3)
  3641. root2    move.b    #':',(a3)
  3642.     lea    88(sp),sp
  3643.     rts
  3644.  
  3645. *ADDPATH A0-> path  A1-> parameter  A2-> destination for string
  3646. ** eg. (A0)='df0:libs',0  (A1)='arp.library',0  (A2)='df0:libs/arp.library',0
  3647. addpath    movem.l a0-a2,-(sp)
  3648.     move.b (a0),d0
  3649.     beq.s addp4
  3650. addp1    move.b (a0)+,d0
  3651.     beq.s addp2
  3652.     move.b d0,(a2)+
  3653.     bra.s addp1
  3654. addp2    move.b -2(a0),d0
  3655.     cmp.b #':',d0
  3656.     beq.s addp4
  3657.     cmp.b #'/',d0
  3658.     beq.s addp4
  3659.     move.b #'/',(a2)+
  3660. addp4    move.l a1,a0
  3661.     move.l a2,a1
  3662.     bsr cp_string
  3663.     movem.l (sp)+,a0-a2
  3664.     rts
  3665.  
  3666.  
  3667. * Search Resident list for command    V2.0:Global resi's
  3668. * RETURN D0=seglist OR 0 if not found
  3669. *    A0=addr of node        D2=addr of Vorgänger
  3670. search_res    move.l    parm1(a5),a4
  3671. search_res2
  3672.     bsr    resi_hand
  3673.     beq.s    .D
  3674.     move.l    a0,d2
  3675. .A    lsl.l    #2,d0
  3676.     move.l    a4,a1            string
  3677.     move.l    d0,a2
  3678.     lea    resi_name(a2),a0    BSTR
  3679.     moveq    #0,d3
  3680.     move.b    (a0)+,d3
  3681.     subq.w    #1,d3
  3682. .B    move.b    (a0)+,d0
  3683.     move.b    (a1)+,d1
  3684.     cmp.b    ctrl_codes+15(a5),d1
  3685.     bne.s    .F
  3686.     tst.b    (a1)
  3687.     beq.s    .C
  3688. .F    bsr    compD1D0nocase
  3689.     dbne    d3,.B
  3690.     bne.s    .E    not equal
  3691.     tst.b    (a1)
  3692.     beq.s    .C    the (null-)END
  3693. .E    move.l    a2,d2
  3694.     move.l    resi_link(a2),d0    get link
  3695.     bne.s    .A
  3696. .D    moveq    #0,d0
  3697.     rts
  3698. .C    moveq    #-1,d1
  3699.     cmp.l    resi_usecount(a2),d1    is it a system-resi ?
  3700.     beq.s    .D
  3701.     move.l    resi_seglist(a2),d0    get seglist
  3702.     move.l    a2,a0
  3703.     rts
  3704.  
  3705.  
  3706. *Search paths for command
  3707. *Exit: d0=seglist, d4=PROGDIR:, branches if script file
  3708. spaths    move.l    parm1(a5),a4    A4=parm1
  3709. spaths2    moveq    #0,d4    jump-in for resident,do not load scripts with it!
  3710.     move.l    thistask(a5),a3
  3711.     lea    pr_CurrentDir(a3),a3    (A3)=ptr to current dir
  3712.     move.l    (a3),d3            d3=current dir at beginning
  3713.     move.l    d3,d4            d4=PROGDIR:
  3714.     bsr    lock_or_load
  3715.     tst.l    d0
  3716.     bne    gotit
  3717.     tst.l    d7
  3718.     beq.s    .C
  3719.     tst.b    forcediskflag(a5)
  3720.     bne.s    .D        do not change dir
  3721.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  3722.     bmi.s    .D            no !
  3723.     addq.l    #4,sp        return from archie3
  3724.     move.l    a4,d1
  3725.     moveq    #ACCESS_READ,d2
  3726.     jsr    _LVOLock(a6)    change current dir
  3727.     move.l    d0,d1
  3728.     bra    chdir
  3729. .D    bsr    s_flagset    exec script ?
  3730.  
  3731. .C    move.l    a4,a0
  3732. .F    move.b    (a0)+,d0    are there path-specific chars in the name
  3733.     cmp.b    #"/",d0
  3734.     beq.s    no_more_paths
  3735.     cmp.b    #":",d0
  3736.     beq.s    no_more_paths
  3737.     tst.b    d0
  3738.     bne.s    .F
  3739.     moveq    #-1,d1
  3740.     bsr    changeWindowPtr        no requesters
  3741.     move.l    CLIptr(a5),a2
  3742.     lea    cli_CommandDir(a2),a2    A2=ptr to current path
  3743.  
  3744. .A    move.l    (a2),d0        search all paths
  3745.     beq.s    .B
  3746.     lsl.l    #2,d0
  3747.     move.l    d0,a2
  3748.     move.l    4(a2),d4    d4=PROGDIR:
  3749.     beq.s    .A
  3750.     move.l    d4,(a3)
  3751.     bsr    lock_or_load    disk access
  3752.     tst.l    d0
  3753.     bne.s    gotit
  3754.     tst.l    d7
  3755.     beq.s    .A
  3756.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  3757.     bpl.s    .A
  3758.     bsr    s_flagset    exec script
  3759.     bra.s    .A
  3760. .B    lea    pathc(pc),a0
  3761.     move.l    a0,d1
  3762.     moveq    #ACCESS_READ,d2
  3763.     jsr    _LVOLock(a6)
  3764.     move.l    d0,d4
  3765.     beq.s    no_more_paths
  3766.     move.l    d4,(a3)
  3767.     move.l    d4,closecdir(a5)
  3768.     bsr    lock_or_load    look in C: dir
  3769.     tst.l    d0
  3770.     bne.s    gotit
  3771. no_more_paths
  3772.     moveq    #0,d0
  3773. gotit    move.l    d3,(a3)        restore current dir
  3774.     moveq    #0,d1        requesters on
  3775.     bra    changeWindowPtr
  3776.  
  3777. lock_or_load
  3778.     move.l    a4,d1
  3779.     moveq    #ACCESS_READ,d2
  3780.     jsr    _LVOLock(a6)
  3781.     move.l    d0,d7
  3782.     beq.s    .A
  3783.     bsr    fibexam2
  3784.     tst.l    fib_DirEntryType(a5)
  3785.     bpl.s    .C
  3786.     move.l    fib_Protection(a5),d0
  3787.     btst    #6,d0    script-bit ?
  3788.     bne.s    .C
  3789.     btst    #1,d0    not-execute-bit ?
  3790.     bne.s    .C
  3791.     move.l    a4,d1
  3792.     jsr    _LVOLoadSeg(a6)
  3793.     tst.l    d0
  3794.     bne.s    .B
  3795.     move.l    d7,d1
  3796.     jsr    _LVOUnLock(a6)
  3797. .A    moveq    #0,d0        file not found
  3798.     rts
  3799. .C    moveq    #0,d0        file is a script or dir
  3800. .B    move.l    d0,-(sp)    file is executable
  3801.     move.l    d7,d1
  3802.     jsr    _LVOUnLock(a6)
  3803.     move.l    (sp)+,d0
  3804.     rts
  3805.  
  3806. s_flagset
  3807.     move.l    fib_Protection(a5),d1
  3808.     btst    #6,d1
  3809.     beq.s    .A
  3810.     move.l    a4,a0    A4 pts to filename
  3811.     bsr    readfile
  3812.     move.l    d3,(a3)        restore current dir
  3813.     addq.l    #8,sp    kill return addresses (archie3,spaths,s_flagset)
  3814.     addq.l    #4,sp
  3815.     bra    xz3
  3816. .A    move.l    #305,d0
  3817.     btst    #1,d1
  3818.     bne    pr_galactic    not-execute-bit
  3819.     rts
  3820.  
  3821. * ARCHIE 3 calls system0 to execute non internal commands
  3822. archie3    tst.l    parm1(a5)        exit if nothing typed
  3823.     beq    noarch31
  3824.     bsr    save_mem
  3825.     clr.b    resi_flag(a5)        =0 if resident
  3826.     bsr    search_res        search resident list first
  3827.     tst.l    d0
  3828.     bne.s    .A
  3829.     addq.b    #1,resi_flag(a5)    =1 if not resident
  3830.     bsr    spaths            load the command
  3831.     tst.l    d0
  3832.     beq    noarch32        could not load
  3833.     cmp.w    #36,kickver(a5)
  3834.     blo.s    .A
  3835.     move.l    thistask(a5),a3
  3836.     move.l    d4,pr_HomeDir(a3)    init PROGDIR:
  3837. .A    move.l    d0,temp1(a5)        save the segment
  3838.     bsr    raw_off
  3839.     bsr    save_time
  3840.     lea    CLIbuf(a5),a0
  3841.     move.l    a0,-(sp)    push arg_args ptr.
  3842.     move.l    d0,-(sp)    push seglist
  3843.     move.l    parm1(a5),d0
  3844.     move.l    d0,-(sp)    push arg_name
  3845.     bsr    _System0    TAKES 3 PARMS(ARG_NAME,SEGLIST,ARGS)
  3846.     lea    12(sp),sp
  3847.     move.l    d0,-(sp)
  3848.     cmp.w    #36,kickver(a5)
  3849.     blo.s    .G
  3850.     move.l    thistask(a5),a3
  3851.     clr.l    pr_HomeDir(a3)        reset PROGDIR:
  3852.     move.l    closecdir(a5),d1
  3853.     beq.s    .G
  3854.     jsr    _LVOUnLock(a6)
  3855.     clr.l    closecdir(a5)
  3856. .G    jsr    _LVOIoErr(a6)
  3857.     move.l    d0,Result2(a5)
  3858.     tst.b    resi_flag(a5)
  3859.     beq.s    .B
  3860.     move.l    better_Seglist(a5),d1
  3861.     jsr    _LVOUnLoadSeg(a6)
  3862. .B    btst    #FLcheck,Flags+3(a5)
  3863.     beq.s    .C
  3864.     bsr    show_status
  3865. .C    bsr    raw_on
  3866.     move.l    (sp)+,d2    RESULT IN D2
  3867.     beq.s    .D
  3868.     btst    #FLerrors,Flags+3(a5)
  3869.     beq.s    .D
  3870.     move.l    Result2(a5),d0
  3871.     beq.s    .D
  3872.     bsr    pr_DOSerr    if result > 0 print error
  3873. .D    move.l    d2,d0    
  3874. noarch31    rts
  3875. noarch32
  3876.     move.l    closecdir(a5),d1    command not found
  3877.     beq.s    .G
  3878.     jsr    _LVOUnLock(a6)
  3879.     clr.l    closecdir(a5)
  3880. .G    lea    badcomm(pc),a1
  3881.     moveq    #RETURN_BAD,d0        return d0 bad
  3882.     bra    pr_string
  3883.  
  3884.  
  3885. *****    SYSTEM0 execute command from disk from Sozobon C distribution.
  3886. _System0
  3887.     movem.l    d2-d3/a2-a6,-(sp)    ;SAVED_REGS
  3888.     moveq    #NO_CLI,REG_Result      ;#-1,d3 ERROR - not a CLI task
  3889.     move.l    4.w,REG_SysBase    ;4,a6
  3890.     move.l    thistask(a5),REG_Process    ;a2
  3891.     move.l    pr_CLI(REG_Process),d0
  3892.     beq    quit0
  3893.  
  3894. * build local stack frame & save some values
  3895.     lsl.l    #2,d0
  3896.     move.l    d0,REG_CLI    ;a3
  3897.     move.l    sp,REG_PrevStack        ;a1 save old stack pointer
  3898.     move.l    sp,d0
  3899.     and.b    #$fc,d0 ;make SP longword-aligned for BPTRs
  3900.     move.l    d0,sp
  3901.     sub.l    #sf_SIZEOF,sp    ;stack-frame-struct
  3902.     move.l    REG_PrevStack,sf_PrevStack(sp)
  3903.     move.l    REG_Process,sf_Process(sp)
  3904.     move.l    REG_CLI,sf_CLI(sp)
  3905.     move.l  pr_ReturnAddr(REG_Process),sf_SaveReturnAddr(sp)
  3906.  
  3907. * allocate space for stack
  3908.     moveq    #NO_MEM,REG_Result    ;ERROR - no memory for STACK
  3909.     move.l    cli_DefaultStack(REG_CLI),d0    ;in longwords for "VEC"
  3910.     lsl.l    #2,d0
  3911.     move.l    d0,sf_PushSize(sp)
  3912.     addq.l    #4,d0    ;one additional longword
  3913.     move.l    d0,sf_StackSize(sp)
  3914.     moveq    #1,d1    ;intentionally NOT "MEMF_PUBLIC"!; V2.0 Why not ?
  3915.     callsys    AllocMem
  3916.     tst.l    d0
  3917.     beq    quit1
  3918.     move.l    d0,sf_StackBase(sp)    ;save result
  3919.  
  3920. * save old command pointer, build new BCPL command name
  3921.     move.l    cli_CommandName(REG_CLI),sf_SaveCommandName(sp)
  3922.     move.l    sf_PrevStack(sp),REG_PrevStack
  3923.     move.l    ARG_NAME(REG_PrevStack),a0 ;first parameter to "System0()"
  3924.     lea    sf_CommandName(sp),a1 ;BSTR
  3925.     move.w    #MAXBSTR-2,d0
  3926.     bsr    cpBSTR
  3927.     move.l    d0,cli_CommandName(REG_CLI)
  3928. * save contents of Current Input Stream
  3929.     move.l    pr_CIS(REG_Process),d0
  3930.     lsl.l    #2,d0
  3931.     move.l    d0,REG_CIS
  3932.     move.l    REG_CIS,sf_CIS(sp)
  3933.     move.l    fh_Buf(REG_CIS),sf_SCB_Buf(sp)
  3934.     move.l    fh_Pos(REG_CIS),sf_SCB_Pos(sp)
  3935.     move.l    fh_End(REG_CIS),sf_SCB_End(sp)
  3936.  
  3937. * convert argument to LF-terminated string
  3938.     move.l    sf_PrevStack(sp),REG_PrevStack
  3939.     move.l    ARG_ARGS(REG_PrevStack),a0 ;third argument to "System0()"
  3940.     lea    sf_CommandArgs(sp),a1    ;first buffer location
  3941.     move.l    a1,d0
  3942.     lsr.l    #2,d0
  3943.     move.l    d0,fh_Buf(REG_CIS)
  3944.     move.w    #MAXBSTR-1,d0    ;leave some room for terminating LF
  3945.     bra.s    .D
  3946. .C    move.b    d1,(a1)+
  3947. .D    move.b    (a0)+,d1
  3948.     dbeq    d0,.C
  3949.     move.b    #LF,(a1)
  3950.     move.l    sf_PrevStack(sp),REG_PrevStack
  3951.     sub.l    ARG_ARGS(REG_PrevStack),a0    ;subtract first position
  3952.     move.l    a0,d0    ;do NOT subtract 1, LF need this byte
  3953. * setup start/end indices in Stream Control Block
  3954.     clr.l   fh_Pos(REG_CIS)
  3955.     move.l  d0,fh_End(REG_CIS)
  3956.  
  3957. * misc setup
  3958.     clr.l    pr_Result2(REG_Process)    ;clear secondary result
  3959.     move.l    a5,sf_Membase(sp)    ;save membase
  3960. ;    moveq    #0,d0
  3961. ;    moveq    #0,d1
  3962. ;    bset    #SIGBREAKB_CTRL_C,d1
  3963. ;    callsys    SetSignal    ;clear CTRL-C flag
  3964.  
  3965. * handle seglist and start address
  3966.     move.l    cli_Module(REG_CLI),sf_SaveModule(sp)
  3967.     move.l    sf_PrevStack(sp),REG_PrevStack
  3968.     move.l    ARG_SEGLIST(REG_PrevStack),d0 ;second argument to "System0()"
  3969.     move.l    d0,cli_Module(REG_CLI)
  3970.     lsl.l    #2,d0
  3971.     move.l    d0,a3
  3972. * setup processor registers & C-interface
  3973.     lea    sf_CommandArgs(sp),a0
  3974.     move.l    fh_End(REG_CIS),d0
  3975. * setup processor registers, BCPL-interface, stack & return address for "Exit()"
  3976.     move.l    sf_StackBase(sp),a1    ;BCPL stack, low end
  3977.     move.l    sf_PushSize(sp),d2
  3978.     lea    4(a1,d2.l),a4    ;must not destroy REG_Process!
  3979.     move.l    sp,-(a4)    ;previous stack frame
  3980.     move.l    d2,-(a4)    :stack size in bytes
  3981.     move.l    a4,pr_ReturnAddr(REG_Process)
  3982.     move.l    a4,sp
  3983.     move.l    dosbase(a5),a4    ;V2.0 small data
  3984.     movem.l    dl_A2(a4),a2/a5/a6
  3985.  
  3986. * now call the command at its entry point
  3987.     jsr    4(a3)    ;code starts one longword behind segment pointer
  3988.     move.l    d0,REG_Result    ;save return code
  3989.  
  3990. * get old stackframe & reload old register contents
  3991.     move.l    4(sp),sp    ;old stack frame
  3992.     move.l    sf_Membase(sp),a5
  3993.     move.l    sf_Process(sp),a0
  3994.     move.l    sf_SaveReturnAddr(sp),pr_ReturnAddr(a0)
  3995.     move.l    sf_CIS(sp),d0
  3996.     move.l    d0,a1
  3997.     lsr.l    #2,d0
  3998.     move.l    d0,pr_CIS(a0)    ;V2.0 restore CIS
  3999.     move.l    sf_CLI(sp),a0
  4000.     move.l    sf_SaveCommandName(sp),cli_CommandName(a0)
  4001. * Next line makes powerpacker programs deallocate memory properly
  4002.     move.l    cli_Module(a0),better_Seglist(a5)    ;V2.0 small data
  4003.     move.l    sf_SaveModule(sp),cli_Module(a0)
  4004. * restore original contents of Current Input Stream
  4005.     move.l    sf_CIS(sp),a0
  4006.     lea    sf_CommandArgs(sp),a1
  4007.     move.l    a1,d0
  4008.     lsr.l    #2,d0
  4009.     cmp.l    fh_Buf(a0),d0    ;still the same?
  4010.     bne.s    .E    ;no: don't restore
  4011.     move.l    sf_SCB_Buf(sp),fh_Buf(a0)
  4012. .E    move.l    sf_SCB_Pos(sp),fh_Pos(a0)
  4013.     tst.l    fh_End(a0)    ;end index set?
  4014.     beq.s    .F    ;no: don't restore
  4015.     move.l    sf_SCB_End(sp),fh_End(a0)
  4016.  
  4017. * free temporary stack
  4018. .F    move.l    4.w,REG_SysBase
  4019.     move.l    sf_StackBase(sp),a1
  4020.     move.l    sf_StackSize(sp),d0
  4021.     callsys    FreeMem
  4022.  
  4023. quit1    move.l    sf_PrevStack(sp),sp    ;UNLINK local variables
  4024. quit0    move.l    REG_Result,d0
  4025.     movem.l    (sp)+,d2-d3/a2-a6    ;SAVED_REGS
  4026. quitx    rts
  4027.  
  4028.  
  4029. *************************
  4030. *    HELP        *
  4031. *************************
  4032. helpz    bsr    rawh_off
  4033.     move.l    parm2(a5),d7
  4034.     bne    help_man
  4035.     lea    helptx1(pc),a1
  4036.     bsr    pr_stringlf
  4037.     lea    comtext(pc),a4
  4038.     lea    tempbuf(a5),a3
  4039. .D    moveq    #5,d3
  4040. .C    move.l    a3,a2
  4041.     tst.b    (a4)        
  4042.     beq    .E
  4043.     moveq    #12,d2
  4044. .B    subq.l    #1,d2
  4045.     move.b    (a4)+,(a2)+
  4046.     bne.s    .B
  4047.     tst.b    -(a2)    bump    back
  4048. .A    move.b    #$20,(a2)+
  4049.     dbra    d2,.A
  4050.     clr.b    (a2)
  4051.     move.l    a3,a1
  4052.     bsr    pr_string
  4053.     dbra    d3,.C
  4054.     bsr    pr_lf
  4055.     bra    .D
  4056. .E    bsr    pr_lf
  4057.     lea    helptx2(pc),a4
  4058.     lea    helptx3(pc),a0
  4059.     move.l    a0,d6
  4060.     bsr    pr_screen
  4061.     moveq    #RETURN_OK,D0
  4062.     rts
  4063.  
  4064. * print out part of manual, d7 points to topic
  4065. help_man lea    manadr(pc),a2    global variable
  4066.     move.l    4(a2),d1
  4067.     move.l    (a2),d0
  4068.     bne.s    .A
  4069.     lea    helpload(pc),a1
  4070.     bsr    pr_string
  4071.     lea    helpman(pc),a0
  4072.     bsr    readfile    load manual
  4073.     move.l    d0,(a2)        manadr
  4074.     move.l    d1,4(a2)    mansize
  4075. .A    move.l    d0,a3
  4076.     move.l    d1,d5
  4077.     add.l    a3,d5
  4078.     move.l    a3,a2
  4079.     move.l    d7,a1        type all ?
  4080.     moveq    #0,d4
  4081.     cmp.b    #"?",(a1)
  4082.     beq    make_screen    type all !
  4083. .B    move.l    d7,a1
  4084.     move.l    d5,a0
  4085.     addq.l    #1,a2
  4086.     bsr    searchSTR    search topic in manual
  4087.     cmp.b    #LF,d0
  4088.     bne.s    .C
  4089.     cmp.b    #"-",-2(a2)    there must be a lot of "-" before topic
  4090.     bne.s    .B
  4091.     cmp.b    #"-",-3(a2)
  4092.     bne.s    .B
  4093.     move.l    a1,d4
  4094. .E    bsr    check_c        ctrl-c ?
  4095.     bne.s    .C
  4096. .D    cmp.l    d5,a1
  4097.     bhi.s    .C
  4098.     cmp.b    #LF,(a1)+    print lines separately
  4099.     bne.s    .D
  4100.     move.l    d4,d2
  4101.     move.l    a1,d3
  4102.     sub.l    d2,d3
  4103.     move.l    a1,d4
  4104.     move.l    outhandle(a5),d1
  4105.     jsr    _LVOWrite(a6)
  4106.     move.l    d4,a1
  4107.     cmp.b    #"-",-2(a1)    search next lot of "-"
  4108.     bne.s    .E
  4109.     cmp.b    #"-",-3(a1)
  4110.     bne.s    .E
  4111.     bra.s    .B        another fitting topic ?
  4112. .C    moveq    #RETURN_OK,D0
  4113.     rts
  4114.  
  4115. giveman    movem.l    d0/d1/a0/a1,-(sp)    free manual-memory
  4116.     lea    manadr(pc),a0
  4117.     tst.l    (a0)
  4118.     beq.s    .A
  4119.     move.l    (a0),a1
  4120.     clr.l    (a0)
  4121.     move.l    4(a0),d0
  4122.     bsr    givemem
  4123. .A    movem.l    (sp)+,d0/d1/a0/a1
  4124.     rts
  4125.  
  4126.  
  4127. * PRINT A STRING BUT PUT A LINEFEED AFTER IT
  4128. pr_stringlf    bsr pr_string
  4129.         bra pr_lf
  4130.  
  4131. *****************    
  4132. *    PATH    *     Assign path or show it.
  4133. *****************
  4134. pathz    lea    parm2(a5),a3
  4135.     move.l    (a3),d0        see whether any parameters
  4136.     beq    ShowPaths
  4137.     move.l    CLIptr(a5),a4
  4138.     lea    cli_CommandDir(a4),a4
  4139.     move.l    d0,a0
  4140.     bsr    return_dash_option
  4141.     cmp.b    #"C",d0
  4142.     bne.s    .F
  4143.     bsr    DeletePaths    * remove all paths
  4144.     addq.l    #4,a3
  4145.  
  4146. .F    moveq    #-1,d3        reverse order
  4147. .G    addq.l    #1,d3
  4148.     tst.l    (a3)+
  4149.     bne.s    .G
  4150.     subq.l    #4,a3
  4151.     bra.s    .D
  4152. .C    move.l    -(a3),d1
  4153.     moveq    #ACCESS_READ,d2    * add as many paths as given
  4154.     jsr    _LVOLock(a6)    get a lock
  4155.     move.l    d0,d2
  4156.     beq    DOSerr
  4157.     bsr    CreatePath
  4158.     beq    resi_no_mem
  4159. .D    dbra    d3,.C
  4160.     moveq    #RETURN_OK,d0
  4161.     rts
  4162.  
  4163. DeletePaths    ;a4=cli_CommandDir, removes all paths
  4164.     move.l    a2,-(sp)
  4165.     move.l    a4,a2
  4166. .A    move.l    (a2),d0
  4167.     beq.s    .B
  4168.     lsl.l    #2,d0
  4169.     move.l    d0,a2
  4170.     move.l    4(a2),d1
  4171.     beq.s    .A
  4172.     jsr    _LVOUnLock(a6)    unlock all paths
  4173.     bra.s    .A
  4174. .B    move.l    (a4),d1
  4175.     beq.s    .E
  4176.     jsr    _LVOUnLoadSeg(a6)    free memory
  4177.     tst.l    d0
  4178.     beq    DOSerr
  4179.     clr.l    (a4)        set path ptr to nil
  4180. .E    move.l    (sp)+,a2
  4181.     rts
  4182.  
  4183. CreatePath    ;d2=Lock, a4=cli_CommandDir
  4184.     moveq    #12,d0
  4185.     moveq    #1,d1
  4186.     bsr    iwantmem    create seglist
  4187.     beq.s    .A
  4188.     move.l    d0,a0
  4189.     addq.l    #4,d0
  4190.     lsr.l    #2,d0
  4191.     moveq    #12,d1
  4192.     move.l    d1,(a0)        size of seglist
  4193.     move.l    (a4),4(a0)    link the new path
  4194.     move.l    d2,8(a0)    bptr to lock
  4195.     move.l    d0,(a4)        first in path-list
  4196. .A    rts
  4197.  
  4198. ShowPaths
  4199.     bsr    rawh_off
  4200.     lea    pcurrent(pc),a1
  4201.     bsr    pr_stringlf
  4202.     move.l    CLIptr(a5),a0
  4203.     lea    cli_CommandDir(a0),a2
  4204. .A    move.l    (a2),d0
  4205.     beq.s    .B
  4206.     lsl.l    #2,d0
  4207.     move.l    d0,a2
  4208.     move.l    4(a2),d1
  4209.     beq.s    .A
  4210.     jsr    _LVODupLock(a6)
  4211.     tst.l    d0
  4212.     beq.s    .A
  4213.     lea    tempbuf(a5),a0
  4214.     bsr    eval_full_path
  4215.     jsr    _LVOUnLock(a6)
  4216.     lea    tempbuf(a5),a1
  4217.     bsr    pr_stringlf
  4218.     bra.s    .A
  4219. .B    lea    pathc(pc),a1
  4220.     bsr    pr_stringlf
  4221.     moveq    #RETURN_OK,d0
  4222.     rts
  4223.  
  4224. CopyPaths    ;copy paths from task in a0 to this task
  4225.     movem.l    d2-d3/a2-a4,-(sp)
  4226.     move.l    thistask(a5),a4
  4227.     move.l    pr_CLI(a4),d0
  4228.     beq.s    .D
  4229.     lsl.l    #2,d0
  4230.     move.l    d0,a4
  4231.     lea    cli_CommandDir(a4),a4
  4232.     move.l    pr_CLI(a0),d0
  4233.     beq.s    .D
  4234.     lsl.l    #2,d0
  4235.     move.l    d0,a0
  4236.     lea    cli_CommandDir(a0),a2
  4237.     lea    tempbuf(a5),a3
  4238.     moveq    #0,d3
  4239. .A    move.l    (a2),d0        * walk through all paths
  4240.     beq.s    .C
  4241.     lsl.l    #2,d0
  4242.     move.l    d0,a2
  4243.     move.l    4(a2),d1
  4244.     beq.s    .A
  4245.     move.l    d1,(a3)+
  4246.     addq.l    #1,d3
  4247.     bra.s    .A
  4248. .B    move.l    -(a3),d1
  4249.     jsr    _LVODupLock(a6)    copy lock
  4250.     move.l    d0,d2
  4251.     beq.s    .C
  4252.     bsr    CreatePath    add path
  4253. .C    dbra    d3,.B
  4254. .D    movem.l    (sp)+,d2-d3/a2-a4    return
  4255.     rts
  4256.  
  4257. *****************
  4258. *    INFO    *
  4259. *****************
  4260. infoz    bsr    rawh_off        ;V2.0 (fully new)
  4261.     lea    inform_tx(pc),a1
  4262.     bsr    pr_stringlf
  4263.     move.l    $22(a6),a0    ;rootnode
  4264.     move.l    $18(a0),a0    ;dosinfo
  4265.     add.l    a0,a0
  4266.     add.l    a0,a0
  4267.     move.l    4(a0),d6    ;devicelist
  4268. jajo    tst.l    d6
  4269.     bne    .B
  4270.     moveq    #RETURN_OK,d0
  4271.     rts
  4272.  
  4273. .B    lsl.l    #2,d6    ;BPTR
  4274.     move.l    d6,a4
  4275.     move.l    (a4),d6        ;next
  4276.     tst.l    4(a4)        ;type
  4277.     bne.s    jajo    ;was volume or assign
  4278.     tst.l    8(a4)        ;task
  4279.     beq.s    jajo    ;was non-disk-device
  4280. didev    move.l    $28(a4),a0    ;name
  4281.     add.l    a0,a0
  4282.     add.l    a0,a0
  4283.     moveq    #0,d0
  4284.     move.b    (a0)+,d0
  4285.     lea    tempbuf(a5),a3
  4286.     move.l    a3,a2
  4287.     bra.s    .D
  4288. .C    move.b    (a0)+,(a2)+
  4289. .D    dbra    d0,.C
  4290.     move.b    #":",(a2)+
  4291.     clr.b    (a2)
  4292.     move.l    8(a4),packettask(a5)    ;aptr task
  4293.     bsr    GetDiskInfo
  4294.     bsr    PKTerr
  4295.     bsr    do_forbid
  4296.     move.l    id_DiskType(a5),d0
  4297.     move.l    d0,d1
  4298.     clr.b    d1
  4299.     cmp.l    #"DOS"<<8,d1
  4300.     beq.s    itsDos        ;DOS-Disk
  4301.     lea    nodisk+1(pc),a0
  4302.     moveq    #-1,d1
  4303.     cmp.l    d1,d0
  4304.     beq.s    .F
  4305.     lea    baddisk(pc),a0
  4306.     cmp.l    #"BAD"<<8,d0
  4307.     beq.s    .F
  4308.     lea    nodos+1(pc),a0
  4309.     cmp.l    #"NDOS",d0
  4310.     beq.s    .F
  4311.     lea    kickdisk(pc),a0
  4312.     cmp.l    #"KICK",d0
  4313.     beq.s    .F
  4314.     lea    inhidisk(pc),a0
  4315. .F    move.l    a0,-(sp)
  4316.     move.l    id_UnitNumber(a5),-(sp)
  4317.     move.l    a3,-(sp)
  4318.     bsr    do_permit
  4319.     lea    (sp),a1
  4320.     lea    inform2(pc),a0
  4321.     bsr    new_print
  4322.     lea    12(sp),sp
  4323.     bra    jajo
  4324.  
  4325. itsDos    move.l    id_VolumeNode(a5),a0    ;DOS-Disk
  4326.     add.l    a0,a0
  4327.     add.l    a0,a0
  4328.     move.l    $28(a0),a0        ;name    (hope, it is NULL-ending)
  4329.     add.l    a0,a0
  4330.     add.l    a0,a0
  4331.     addq.l    #1,a0
  4332.     move.l    a0,-(sp)
  4333.     move.l    id_NumSoftErrors(a5),-(sp)    ;SoftErrors
  4334.     move.l    id_DiskState(a5),d0
  4335.     lea    statro(pc),a0
  4336.     moveq    #80,d1
  4337.     cmp.l    d1,d0
  4338.     beq.s    .H
  4339.     lea    statrw(pc),a0
  4340.     moveq    #82,d1
  4341.     cmp.l    d1,d0
  4342.     beq.s    .H
  4343.     lea    statval(pc),a0
  4344.     moveq    #81,d1
  4345.     cmp.l    d1,d0
  4346.     beq.s    .H
  4347.     lea    statun(pc),a0
  4348. .H    move.l    a0,-(sp)        ;Status
  4349.     move.l    id_BytesPerBlock(a5),d1
  4350.     move.l    d1,-(sp)        ;BlockSize
  4351.     move.l    id_NumBlocks(a5),d0
  4352.     bsr    mult_32x32
  4353.     lsr.l    #8,d0
  4354.     lsr.l    #2,d0
  4355.     move.l    d0,d2
  4356.     move.l    id_NumBlocksUsed(a5),d0
  4357.     bsr    mult_32x32
  4358.     lsr.l    #8,d0
  4359.     lsr.l    #2,d0
  4360.     move.l    d2,d3
  4361.     sub.l    d0,d3
  4362.     moveq    #100,d1
  4363.     bsr    mult_32x32
  4364.     move.l    d2,d1
  4365.     beq.s    .D
  4366.     bsr    div_32    ;%
  4367. .D    exg    d0,d2
  4368.     move.l    d3,d1
  4369.     movem.l    d0-d2,-(sp)        ;Sizes
  4370.     lea    msd_tx(pc),a0    messydos ?
  4371.     move.l    $1c(a4),d0    dn_Startup
  4372.     moveq    #2,d1
  4373.     cmp.l    d1,d0
  4374.     bls.s    .A
  4375.     lsl.l    #2,d0
  4376.     move.l    d0,a1
  4377.     move.l    8(a1),d0    fssm_Environ
  4378.     beq.s    .A
  4379.     lsl.l    #2,d0
  4380.     move.l    d0,a1
  4381.     move.l    64(a1),d0    de_DosType
  4382.     cmp.l    #"MSD"<<8,d0    CrossDos ?
  4383.     beq.s    .C
  4384. .A    move.l    id_DiskType(a5),d0
  4385.     lea    quest_tx(pc),a0
  4386.     cmp.b    #5,d0
  4387.     bhi.s    .C    unknown
  4388.     ext.w    d0
  4389.     ext.l    d0
  4390.     lea    ofs_tx(pc),a0
  4391.     lsl.l    #2,d0
  4392.     add.l    d0,a0    d0*4+a0    access table
  4393. .C    move.l    a0,-(sp)        ;System
  4394.     move.l    id_UnitNumber(a5),-(sp)    ;Unit
  4395.     move.l    a3,-(sp)        ;Name
  4396.     bsr    do_permit
  4397.     lea    (sp),a1
  4398.     lea    inform(pc),a0
  4399.     bsr    new_print
  4400.     lea    40(sp),sp
  4401.     bra    jajo
  4402.  
  4403.  
  4404.  
  4405. *****************
  4406. *    ENDCLI    *    EXIT FROM ZSHELL TO CLI.
  4407. *****************    IF WE EXIT FROM SCRIPT THEN FREE SCRIPT MEMORY
  4408. endcliz    bsr    raw_off
  4409.     move.l    parm2(a5),a0
  4410.     bsr    return_dash_option
  4411.     moveq    #-1,d7
  4412.     cmp.b    #'C',d0
  4413.     bne.s    .A
  4414.     moveq    #0,d7
  4415. .A    tst.b    scflag(a5)
  4416.     beq.s    byebye
  4417.     bsr    kill_script
  4418. byebye    move.l    (sp)+,d0    ;kill return address on stack
  4419.     rts
  4420.  
  4421. ** CHECK DIRECTORY DESCRIPTION IN (A0) AND CONVERTS INTO DIRNAME[0] AND PUTS
  4422. ** THE WILD CARD IN WILD_STRING. ALSO SETS WILD_FLAG
  4423. handle_wild_dirs
  4424.     clr.b    wild_flag(a5)
  4425.     btst    #FLwild,Flags+3(a5)
  4426.     beq.s    .B
  4427.     cmp.w    #37,kickver(a5)
  4428.     blo.s    .B
  4429.     movem.l    d2-d3/a0,-(sp)
  4430.     lea    tempbuf(a5),a1
  4431.     move.l    a1,d1
  4432.     bsr    rempath
  4433.     lea    NewPrintBuffer(a5),a0
  4434.     move.l    a0,d2
  4435.     moveq    #120,d3
  4436.     jsr    _LVOParsePatternNC(a6)    external matcher
  4437.     movem.l    (sp)+,d2-d3/a0
  4438.     tst.l    d0
  4439.     bmi.s    .A
  4440.     bne.s    .C
  4441. .B    bsr    check_wild    internal matcher
  4442.     tst.b    d0
  4443.     bne.s    .A
  4444. .C    lea    wild_string(a5),a1
  4445.     bsr    split_wild
  4446.     move.b    #1,wild_flag(a5)
  4447. .A    rts    
  4448.  
  4449. ** SPLIT STRING(A0) INTO DIRECTORY PATH AND WILDCARD DESCRIPTION
  4450. ** NULL END THE PATH, AND MOVE THE WILDCARD TO (A1)
  4451. * eg. ram:c/*.info -> ram:c0 + *.info0    
  4452. split_wild
  4453.     movem.l    d0-d1/a0-a2,-(sp)
  4454.     move.l    a0,d1
  4455. sp_w2    move.l    a0,a2    a2=temp
  4456. sp_w3    move.b    (a0)+,d0
  4457.     beq.s    sp_w4
  4458.     cmp.b    #':',d0
  4459.     beq.s    sp_w2    A0= 1 after :
  4460.     cmp.b    #'/',d0
  4461.     beq.s    sp_w2
  4462.     bra.s    sp_w3
  4463. sp_w4    cmp.l    a2,d1
  4464.     beq.s    sp_mis
  4465.     cmp.b    #':',-1(a2)
  4466.     bne.s    sp_w5
  4467. sp_mis    move.l    a2,d1    SAVE POSITION
  4468. sp_w6    move.b    (a2)+,(a1)+
  4469.     bne.s    sp_w6
  4470.     move.l    d1,a2
  4471.     clr.b    (a2)
  4472.     movem.l    (sp)+,d0-d1/a0-a2
  4473.     rts
  4474. sp_w5    clr.b    -1(a2)
  4475. sp_w7    move.b    (a2)+,(a1)+
  4476.     bne.s    sp_w7
  4477.     movem.l    (sp)+,d0-d1/a0-a2
  4478.     rts
  4479.     
  4480. ** CHECK STRING(A0) IF IT CONTAINS WILDCARD SPECIFIC CHARS
  4481. ** RETURN D0=0 IF WILDS FOUND
  4482. check_wild    ;only used by handle_wild_dirs
  4483.     move.l    a0,-(sp)
  4484. chk_w3    move.b    (a0)+,d0
  4485.     beq.s    chk_w2
  4486.     cmp.b    #'*',d0
  4487.     beq.s    chk_w4
  4488.     cmp.b    #'~',d0    special not char
  4489.     beq.s    chk_w4
  4490.     cmp.b    #'[',d0
  4491.     beq.s    chk_w4
  4492.     cmp.b    #']',d0
  4493.     beq.s    chk_w4
  4494.     cmp.b    #'|',d0 or char
  4495.     beq.s    chk_w4
  4496.     cmp.b    #'?',d0
  4497.     bne.s    chk_w3
  4498. chk_w4    moveq    #0,d0
  4499.     move.l    (sp)+,a0
  4500.     rts
  4501. chk_w2    moveq    #1,d0
  4502.     move.l    (sp)+,a0
  4503.     rts
  4504.  
  4505. * NOTE this wildmatcher only handles cases where the wildcard has one * in it.
  4506. ** WILDCARD MATCHER. CHECK IF STRING(A0) MATCHES WILDCARD(A1)
  4507. ** RETURN D0=0 IF MATCH
  4508. wildmatch2
  4509.     btst    #FLwild,Flags+3(a5)
  4510.     beq.s    wildmatch
  4511.     cmp.w    #37,kickver(a5)
  4512.     blo.s    wildmatch
  4513.     movem.l    d2/a0/a1,-(sp)
  4514.     move.l    a0,d2
  4515.     lea    NewPrintBuffer(a5),a0
  4516.     move.l    a0,d1
  4517.     jsr    _LVOMatchPatternNC(a6)    external matcher
  4518.     movem.l    (sp)+,d2/a0/a1
  4519.     moveq    #0,d1
  4520.     tst.l    d0
  4521.     bne.s    .A
  4522.     addq.l    #1,d1
  4523. .A    move.l    d1,d0
  4524.     rts
  4525. wildmatch movem.l    d2/a2-a3,-(sp)
  4526.     move.b    (a1),d2
  4527.     cmp.b    #"~",d2        ;check if all is negated
  4528.     bne.s    .C
  4529.     addq.l    #1,a1
  4530. .C    move.l    a1,a2
  4531.     move.l    a0,a3
  4532. .A    move.b    (a2)+,d0
  4533.     beq.s    .B
  4534.     cmp.b    #"|",d0        ;or-symbol  V2.0
  4535.     bne.s    .A
  4536.     move.b    #0,-1(a2)    ;change wildcard to end
  4537.     bsr.s    wildermatch
  4538.     move.b    #"|",-1(a2)    ;restore
  4539.     tst.l    d0
  4540.     beq.s    gut
  4541.     lea    (a3),a0
  4542.     lea    (a2),a1
  4543.     bra.s    .A
  4544. .B    bsr.s    wildermatch
  4545. gut    cmp.b    #"~",d2
  4546.     bne.s    .D
  4547.     subq.l    #1,d0
  4548. .D    movem.l    (sp)+,d2/a2-a3
  4549.     rts
  4550.  
  4551. wildermatch
  4552.     cmp.b    #'~',(a1)        check for NOT specifier
  4553.     bne.s    wm_1
  4554.     move.b    (a1)+,d0
  4555.     bsr.s    wm_1
  4556.     subq.l    #1,d0    0 --> -1     1 --> 0
  4557.     rts
  4558.     
  4559. wm_1    move.b    (a0)+,d0
  4560.     beq    source_fin1
  4561.     move.b    (a1)+,d1
  4562.     cmp.b    #'*',d1
  4563.     beq.s    wild_run
  4564.     cmp.b    #'[',d1        handle character classes
  4565.     bne.s    .A
  4566. .B    move.b    (a1)+,d1
  4567.     beq.s    wild_fail
  4568.     cmp.b    #']',d1
  4569.     beq.s    wild_fail
  4570.     bsr    compD1D0nocase
  4571.     bne.s    .B
  4572. .C    move.b    (a1)+,d1
  4573.     beq.s    wild_fail
  4574.     cmp.b    #']',d1
  4575.     bne.s    .C
  4576.     bra.s    wm_1
  4577. .A    cmp.b    #'?',d1
  4578.     beq.s    wm_1
  4579.     bsr    compD1D0nocase
  4580.     beq.s    wm_1
  4581.     
  4582. wild_fail    moveq    #1,d0
  4583.     rts
  4584. wild_run    
  4585. wr_3    tst.b    (a0)+    GOTO END OF STRING
  4586.     bne.s    wr_3
  4587. wr_4    tst.b    (a1)+    GOTO END OF WILDCARD
  4588.     bne.s    wr_4
  4589. wr_5    move.b    -(a1),d0    get tail of wildcard (1st should be null)
  4590.     move.b    -(a0),d1
  4591.     cmp.b    #'*',d0
  4592.     beq.s    source_fin2
  4593.     cmp.b    #']',d0        handle class [xyz]
  4594.     bne.s    .A
  4595. .B    move.b    -(a1),d0
  4596.     cmp.b    #'*',d0
  4597.     beq.s    wild_fail
  4598.     cmp.b    #'[',d0
  4599.     beq.s    wild_fail
  4600.     bsr    compD1D0nocase
  4601.     bne.s    .B
  4602. .C    move.b    -(a1),d0
  4603.     beq.s    wild_fail    should never happen but should leave in
  4604.     cmp.b    #'[',d0
  4605.     bne.s    .C
  4606.     bra.s    wr_5
  4607. .A    cmp.b    #'?',d0
  4608.     beq.s    wr_5
  4609.     bsr    compD1D0nocase
  4610.     beq.s    wr_5
  4611.     bra.s    wild_fail
  4612. source_fin1
  4613.     tst.b    (a1)
  4614.     beq.s    source_fin2
  4615.     cmp.b    #'*',(a1)
  4616.     bne.s    wild_fail
  4617. source_fin2
  4618.     moveq    #0,d0
  4619.     rts
  4620.  
  4621. compD1D0nocase    ;lowercase d0 and d1 then compare them
  4622.     cmp.b    #'Z',d1
  4623.     bhi.s    D1_OK
  4624.     cmp.b    #'A',d1
  4625.     blo.s    D1_OK
  4626.     add.b    #$20,d1
  4627. D1_OK    cmp.b    #'Z',d0
  4628.     bhi.s    D0_OK
  4629.     cmp.b    #'A',d0
  4630.     blo.s    D0_OK
  4631.     add.b    #$20,d0
  4632. D0_OK    cmp.b    d1,d0
  4633.     rts
  4634.     
  4635. fibexnx    move.l    d7,d1
  4636.     move.l    a5,d2
  4637.     jsr    _LVOExNext(a6)
  4638.     rts
  4639.  
  4640. *********************************
  4641. *    DIRECTORY LISTER    *
  4642. *********************************
  4643. fname    equ    40    for sorting
  4644.  
  4645. dirz    clr.l    temp2(a5)        WIDE DIR, 2 columns
  4646.     bset.l    #31,temp2(a5)        bit 31=wide flag
  4647.     bra.s    directory
  4648.  
  4649. listz    clr.l    temp2(a5)        NARROW DIR, clear wide flag
  4650.     bset.l    #29,temp2(a5)        bit 29=verbose flag
  4651.     bset.l    #28,temp2(a5)        bit 28=comment flag
  4652. directory        ;V2.0:many things better (sort!)
  4653.     bsr    check_q_r
  4654. directory2
  4655.     lea    parm2(a5),a2
  4656.     bsr    rawh_off
  4657.     move.l    (a2),d1
  4658.     bne.s    .A
  4659.     lea    null(pc),a0
  4660.     move.l    a0,d1
  4661.     bra.s    .B
  4662.  
  4663. .A    move.l    (a2)+,d1    list all parms
  4664.     beq.s    .C
  4665. .B    move.l    a2,-(sp)
  4666.     move.l    d1,a2
  4667.     bsr    DirLister
  4668.     move.l    (sp)+,a2
  4669.     tst.l    d0
  4670.     bne.s    .E
  4671.     tst.b    break_flag(a5)
  4672.     beq.s    .A
  4673. .C    moveq    #RETURN_OK,d0
  4674. .E    rts
  4675.  
  4676. DirLister    ;wants dirname or filename in a2
  4677. *temp2-bits:    31:wide dir: DIR
  4678. *        30:quick, nosort: (all)
  4679. *        29:verbose list: LIST
  4680. *        28:comment: LIST
  4681. *        27:footer: (auto)
  4682. *        26:delete file: DELETE,MOVE
  4683. *        25:not process file: DELETE,COPY,MOVE
  4684. *        24:protect: PROTECT
  4685. *        23:copy: COPY,MOVE
  4686. *        22:move: MOVE
  4687. *        21:rename: MOVE
  4688. *        20:join: JOIN
  4689.     clr.l    temp1(a5)            init total size
  4690.     and.l    #$fff00000,temp2(a5)
  4691.     clr.l    temp3(a5)
  4692.     clr.l    temp4(a5)
  4693.     bset    #21,temp2+1(a5)
  4694.     btst.l    #31,temp2(a5)
  4695.     beq.s    .A
  4696.     bset    #0,temp2+3(a5)
  4697. .A    btst.l    #30,temp2(a5)
  4698.     beq.s    .B
  4699.     bclr    #28,temp2(a5)
  4700. .B    clr.w    indent_count(a5)
  4701.     move.l    a2,a0
  4702.     bsr    handle_wild_dirs
  4703.     lea    tempbuf(a5),a4
  4704. .C    move.b    (a2)+,(a4)+
  4705.     bne.s    .C
  4706.     bsr    pr_dir            -> print the dir
  4707.  
  4708. pr_size    movem.l    d0-d3,-(sp)        end of dirlister
  4709.     move.l    temp2(a5),d0        are we printing wide
  4710.     bpl.s    .B
  4711.     btst.l    #0,d0
  4712.     bne.s    .B
  4713.     bsr    pr_lf            print missing lf
  4714. .B    lea    (sp),a1
  4715.     lea    totsize(pc),a0
  4716.     btst    #27,temp2(a5)
  4717.     beq.s    .A
  4718.     bsr    new_print        print footer
  4719. .A    lea    16(sp),sp
  4720.     moveq    #RETURN_OK,d0
  4721.     rts
  4722.  
  4723. pr_dir    bset    #27,temp2(a5)
  4724.     bclr    #25,temp2(a5)
  4725.     lea    tempbuf(a5),a0
  4726.     bsr    fibexam
  4727.     bsr    fixsoftlink
  4728.     btst    #24,temp2(a5)        protect flag ?
  4729.     bne.s    .D
  4730.     btst    #26,temp2(a5)        delete flag ?
  4731.     beq.s    .B
  4732. .D    tst.b    wild_flag(a5)
  4733.     beq.s    .C
  4734. .B    tst.l    fib_DirEntryType(a5)    check entry OK
  4735.     bpl.s    prd20            print whole Directory
  4736.  
  4737. .C    bsr    check_c
  4738.     bne.s    .F
  4739.     move.l    d7,d1
  4740.     jsr    _LVOUnLock(a6)        unlock file
  4741.     lea    tempbuf(a5),a0
  4742.     lea    temp2buf(a5),a1
  4743.     bsr    split_wild        separate path and filename
  4744.     lea    tempbuf(a5),a0
  4745.     move.l    a0,d1
  4746.     moveq    #ACCESS_READ,d2
  4747.     jsr    _LVOLock(a6)        get a lock on the dir
  4748.     move.l    d0,d7
  4749.     bsr    pr_it            print single file/dir
  4750.     bclr    #27,temp2(a5)        do not print footer
  4751. .F    bsr    unlock            make sure to unlock
  4752.     rts
  4753.  
  4754. prd20    tst.w    indent_count(a5)    was a dir
  4755.     bne.s    .A
  4756.     move.l    d7,d1
  4757.     jsr    _LVOUnLock(a6)
  4758.     lea    tempbuf(a5),a0
  4759.     move.l    a0,d1
  4760.     moveq    #ACCESS_READ,d2
  4761.     jsr    _LVOLock(a6)
  4762.     lea    temp2buf(a5),a0        get full dir name for later
  4763.     clr.b    (a0)
  4764.     tst.l    d0
  4765.     beq    DOSerr
  4766.     bsr    eval_full_path
  4767.     jsr    _LVOUnLock(a6)
  4768.     lea    dirof(pc),a1
  4769.     bsr    pr_string
  4770.     lea    temp2buf(a5),a1
  4771.     bsr    pr_stringlf        print directory's name
  4772.     lea    tempbuf(a5),a0
  4773.     bsr    fibexam
  4774.  
  4775. .A    sub.l    a3,a3    ;clr a3
  4776. prd2
  4777.     bsr    check_c        CTRL-C pressed ?
  4778.     bne    unlk
  4779.     bsr    fibexnx
  4780.     tst.l    d0
  4781.     beq    unlk        ;sort ?
  4782.     bsr    fixsoftlink
  4783.     move.l    temp2(a5),d0
  4784.     btst    #31,d0
  4785.     beq.s    .C
  4786.     move.l    fib_Protection(a5),d0
  4787.     btst    #7,d0
  4788.     bne.s    prd2    hide if hide flag is set in wide dir lister
  4789.     lea    ignoreit(a5),a1        hide ctrl-ignore
  4790.     tst.b    (a1)
  4791.     beq.s    .C
  4792.     lea    fib_FileName(a5),a0
  4793.     bsr    wildmatch        wildcheck
  4794.     tst.b    d0
  4795.     beq.s    prd2
  4796. .C    tst.b    wild_flag(a5)
  4797.     beq.s    dozel
  4798.     tst.b    recurs_flag(a5)
  4799.     beq.s    .A
  4800.     tst.l    fib_DirEntryType(a5)
  4801.     bpl.s    dozel
  4802. .A    lea    fib_FileName(a5),a0
  4803.     lea    wild_string(a5),a1
  4804.     bsr    wildmatch2        wildcheck (can be external)
  4805.     tst.b    d0
  4806.     bne.s    prd2
  4807. dozel    btst.l    #30,temp2(a5)
  4808.     beq.s    collect            not quick
  4809.     btst    #26,temp2(a5)
  4810.     bne.s    collect            delete
  4811.     bsr    zelma
  4812.     bra.s    prd2
  4813.  
  4814. collect moveq    #fname,d0        collect files to sort  V2.0
  4815.     lea    fib_FileName(a5),a0
  4816.     lea    (a0),a2
  4817. .A    addq.l    #1,d0
  4818.     tst.b    (a0)+
  4819.     bne.s    .A
  4820.     lea    fib_Comment(a5),a0
  4821. .B    addq.l    #1,d0
  4822.     tst.b    (a0)+
  4823.     bne.s    .B
  4824.     moveq    #1,d1
  4825.     bsr    iwantmem
  4826.     beq    unlock
  4827.     move.l    d0,a0
  4828.     move.l    a3,(a0)+
  4829.     lea    -4(a0),a3
  4830.     lea    fib_DiskKey(a5),a1    ;store fib in mem
  4831.     move.l    (a1)+,(a0)+
  4832.     move.l    (a1)+,(a0)+
  4833.     lea    fib_Protection(a5),a1
  4834.     moveq    #6,d1
  4835. .C    move.l    (a1)+,(a0)+
  4836.     dbra    d1,.C
  4837. .D    move.b    (a2)+,(a0)+    ;name
  4838.     bne.s    .D
  4839. .E    move.b    (a1)+,(a0)+    ;comment
  4840.     bne.s    .E
  4841.     bra    prd2
  4842.  
  4843. unlk    btst.l    #26,temp2(a5)
  4844.     bne.s    .A        delete
  4845.     btst.l    #30,temp2(a5)
  4846.     bne    unlock        quick
  4847. .A    move.l    a3,d0    
  4848.     beq    unlock        no files
  4849.     tst.b    break_flag(a5)
  4850.     bne.s    nextfi        CTRL-C pressed
  4851.  
  4852.     movem.l    a4-a6,-(sp)
  4853.     btst.l    #30,temp2(a5)
  4854.     bne.s    snull        quick
  4855.     lea    (a3),a0        ;INSERTION SORT  V2.0   (ooohuuooo)
  4856. aussort    lea    (a3),a1
  4857.     move.l    (a0),a2    ;remove (a0->) a2
  4858.     move.l    a2,d0
  4859.     beq.s    snull    ;end of list
  4860.     move.l    (a2),(a0)
  4861.     bsr    strcmp    ;compare a1 and a2
  4862.     bne.s    insort    ;insert a2 (old place)
  4863.     move.l    a2,a3    ;a2->start
  4864.     move.l    a1,(a2)    ;a1=old start
  4865.     bra.s    aussort    ;next
  4866. insort    move.l    a1,a4    ;reminder
  4867.     move.l    (a1),a1    ;next a1
  4868.     cmp.l    a0,a4
  4869.     beq.s    inold
  4870. shno    bsr    strcmp    ;compare a1 and a2
  4871.     bne.s    insort    ;go on
  4872.     move.l    a2,(a4)    ;insert a2
  4873.     move.l    a1,(a2)    ;a4->a2->a1
  4874.     bra.s    aussort
  4875. inold    move.l    (a0),(a2) ;a2 back at old place
  4876.     move.l    a2,(a0)    ;a0->a2->next
  4877.     move.l    a2,a0    ;next a0
  4878.     bra.s    aussort
  4879. snull    movem.l    (sp)+,a4-a6    ;FINISHED !!!
  4880.  
  4881.     tst.l    temp2(a5)    for normal DIR
  4882.     bpl.s    nextfi
  4883.     tst.b    recurs_flag(a5)
  4884.     bne.s    nextfi
  4885.     moveq    #1,d0        prepare for printing in 2 columns
  4886.     move.l    a3,d1
  4887. .A    addq.l    #1,d0
  4888.     move.l    d1,a0
  4889.     move.l    (a0),d1
  4890.     bne.s    .A        count number of entries (d0)
  4891.     lsr.l    #1,d0        divide by two
  4892.     move.l    a3,a2
  4893.     bra.s    .B
  4894. .C    move.l    a2,a0
  4895.     move.l    (a2),a2
  4896. .B    dbra    d0,.C        find the middle    (a2 ,precedor in a0)
  4897.     clr.l    (a0)
  4898.  
  4899. nextfi    lea    4(a3),a1    print all files
  4900.     lea    fib_DiskKey(a5),a0    ;restore fib from mem
  4901.     move.l    (a1)+,(a0)+
  4902.     move.l    (a1)+,(a0)+
  4903.     lea    fib_Protection(a5),a0
  4904.     moveq    #6,d1
  4905. .F    move.l    (a1)+,(a0)+
  4906.     dbra    d1,.F
  4907.     moveq    #fname,d0
  4908.     lea    fib_FileName(a5),a0
  4909. .H    addq.l    #1,d0
  4910.     move.b    (a1)+,(a0)+    ;name
  4911.     bne.s    .H
  4912.     lea    fib_Comment(a5),a0
  4913. .B    addq.l    #1,d0
  4914.     move.b    (a1)+,(a0)+    ;comment
  4915.     bne.s    .B
  4916.     movem.l    d0/a2/a3,-(sp)
  4917.     tst.b    break_flag(a5)
  4918.     bne.s    .C        CTRL-C pressed
  4919.     bsr    check_c
  4920.     bne.s    .C
  4921.     bsr    zelma
  4922. .C    movem.l    (sp)+,d0/a2/a3
  4923.     move.l    (a3),d2
  4924.     lea    (a3),a1
  4925.     bsr    givemem
  4926.     move.l    d2,a3
  4927.     tst.l    temp2(a5)
  4928.     bpl.s    .A
  4929.     tst.b    recurs_flag(a5)
  4930.     bne.s    .A
  4931.     move.l    a2,a0        swap lower and upper list
  4932.     move.l    a3,a2
  4933.     move.l    a0,a3
  4934. .A    move.l    a3,d0        tst.l    a3
  4935.     bne    nextfi
  4936.  
  4937. unlock    move.l    d7,d1
  4938.     jsr    _LVOUnLock(a6)
  4939.     move.l    temp1(a5),d0    ;total size
  4940.     move.l    temp4(a5),d1
  4941.     move.l    temp2(a5),d2    ;No. of files and dirs
  4942.     btst.l    #31,d2
  4943.     beq.s    .A
  4944.     subq.l    #1,d2
  4945. .A    and.l    #$000fffff,d2    ;1.000.000 files max. should be enough
  4946.     move.l    temp3(a5),d3    ;No. of dirs
  4947.     sub.l    d3,d2
  4948.     rts
  4949.  
  4950. strcmp    move.l    8(a1),d0
  4951.     move.l    8(a2),d1
  4952.     bmi.s    .A
  4953.     tst.l    d0    a2 is dir
  4954.     bpl.s    .B    a1 is dir too
  4955.     bra.s    donoth    a2:dir    a1:file
  4956. .A    tst.l    d0    a2 is file
  4957.     bpl.s    inseit    a2:file    a1:dir
  4958. .B    lea    fname(a1),a5    a1 is file too
  4959.     lea    fname(a2),a6
  4960. stcmp    move.b    (a5)+,d1    ;compare strings in a3 and a4
  4961.     beq.s    donoth
  4962.     move.b    (a6)+,d0
  4963.     beq.s    inseit
  4964.     bsr    compD1D0nocase
  4965.     beq.s    stcmp
  4966.     bhi.s    donoth
  4967. inseit    moveq    #0,d0        ;insert it !
  4968.     rts
  4969. donoth    moveq    #1,d0        ;do nothing !
  4970.     rts
  4971.  
  4972.  
  4973. zelma    tst.l    fib_DirEntryType(a5)
  4974.     bpl.s    .C
  4975.     bsr    pr_it        print file
  4976.     rts
  4977. .C    tst.b    recurs_flag(a5)
  4978.     bne.s    .B
  4979.     bsr    pr_it        print dir
  4980. .A    rts
  4981. .B    bset    #25,temp2(a5)    do not process this dir
  4982.     bsr    pr_it        print dir recursive
  4983.     bclr    #25,temp2(a5)
  4984.     move.w    temp2(a5),d0
  4985.     and.w    #%0000010010010000,d0    copy,delete or join flag
  4986.     beq.s    .D        no
  4987.     btst    #23,temp2+1(a5)    copy ?
  4988.     beq.s    .E
  4989.     move.l    temp5(a5),d1    yes:create new dir
  4990.     bsr    CurrentDir
  4991.     move.l    d0,d3
  4992.     lea    fib_FileName(a5),a2    copy: create dir
  4993.     move.l    a2,d1
  4994.     jsr    _LVOCreateDir(a6)
  4995.     move.l    d0,d2
  4996.     bne.s    .F
  4997. .G    move.l    d3,d1
  4998.     bsr    CurrentDir
  4999.     jsr    _LVOIoErr(a6)
  5000.     move.l    d0,d2
  5001.     bsr    pr_lf
  5002.     move.l    d2,d0
  5003.     bsr    pr_DOSerr
  5004.     rts
  5005. .F    move.l    d2,d1        unlock new dir, because is exclusive
  5006.     jsr    _LVOUnLock(a6)
  5007.     move.l    a2,d1
  5008.     moveq    #ACCESS_READ,d2
  5009.     jsr    _LVOLock(a6)
  5010.     move.l    d0,d2
  5011.     beq.s    .G
  5012.     move.l    d3,d1
  5013.     bsr    CurrentDir
  5014.     move.l    temp5(a5),d1    unlock old in temp5
  5015.     jsr    _LVOUnLock(a6)
  5016.     move.l    d2,temp5(a5)
  5017.     lea    makedirOK(pc),a1
  5018.     bsr    pr_string
  5019.     bsr    AdjustPath
  5020.     bra.s    .D
  5021. .E    bsr    pr_lf        no copy: just print lf
  5022.  
  5023. .D    moveq    #120,d0    ;(24bytes per recurs + subs + move-path)
  5024.     bsr    stacktest
  5025.     bne    .A
  5026.     move.l    fib_DiskKey(a5),d0
  5027.     movem.l    d0/d7/a4,-(sp)
  5028.     lea    fib_FileName(a5),a0
  5029.     lea    -1(a4),a4
  5030.     lea    tempbuf(a5),a1
  5031.     cmp.l    a1,a4
  5032.     beq.s    jo
  5033.     cmp.b    #":",-1(a4)
  5034.     beq.s    jo
  5035.     move.b    #"/",(a4)
  5036.     lea    1(a4),a4
  5037. jo    move.b    (a0)+,(a4)+        ;addpath
  5038.     bne.s    jo
  5039.     addq.w    #2,indent_count(a5)
  5040. jojo    bsr    pr_dir            RECURSION    V2.0
  5041.     subq.w    #2,indent_count(a5)
  5042.     movem.l    (sp)+,d0/d7/a4
  5043.     move.l    d0,fib_DiskKey(a5)    ;restore fib
  5044.     lea    -1(a4),a0
  5045.     cmp.b    #"/",(a0)
  5046.     bne.s    .D
  5047.     clr.b    (a0)
  5048.     lea    1(a0),a0
  5049. .D    lea    (a0),a2
  5050.     lea    fib_FileName(a5),a1
  5051. je    move.b    (a0)+,(a1)+
  5052.     bne.s    je
  5053.     clr.b    (a2)
  5054.     moveq    #2,d0
  5055.     move.l    d0,fib_DirEntryType(a5)
  5056.     move.l    d0,fib_EntryType(a5)
  5057.     moveq    #0,d0
  5058.     move.l    d0,fib_Size(a5)
  5059.     move.l    d0,fib_NumBlocks(a5)
  5060.     btst    #23,temp2+1(a5)    copy ?
  5061.     beq.s    .B
  5062.     move.l    temp5(a5),d2    COPY
  5063.     move.l    d2,d1
  5064.     jsr    _LVOParentDir(a6)
  5065.     move.l    d0,temp5(a5)
  5066.     move.l    d2,d1
  5067.     jsr    _LVOUnLock(a6)
  5068.     bsr    AdjustPath
  5069. .B    btst    #26,temp2(a5)    delete ?
  5070.     beq.s    .A
  5071.     move.l    temp2(a5),-(sp)
  5072.     bclr    #22,temp2+1(a5)    move off
  5073.     bsr    pr_it        now delete this dir
  5074.     move.l    (sp)+,temp2(a5)
  5075. .A    rts
  5076.  
  5077. AdjustPath
  5078.     btst    #22,temp2+1(a5)
  5079.     beq.s    .D
  5080.     btst    #21,temp2+1(a5)
  5081.     beq.s    .D
  5082.     move.l    temp5(a5),d1
  5083.     jsr    _LVODupLock(a6)
  5084.     tst.l    d0
  5085.     beq    DOSerr
  5086.     move.l    temp7(a5),a0
  5087.     bsr    eval_full_path
  5088.     jsr    _LVOUnLock(a6)
  5089. .D    rts
  5090.  
  5091. pr_it    bsr    num_spc            print file or dir
  5092.     tst.l    fib_DirEntryType(a5)    check whether is dir
  5093.     bmi.s    .A            if plus,is directory
  5094.     move.l    temp2(a5),d0        check for "DIR -R"
  5095.     bpl.s    .G
  5096.     tst.b    recurs_flag(a5)
  5097.     beq.s    .G
  5098.     btst    #0,d0
  5099.     bne.s    .H
  5100.     subq.l    #1,temp2(a5)
  5101.     bsr    pr_lf            for DIR -R directories
  5102. .H    addq.l    #1,temp2(a5)
  5103. .G    lea    farb3(pc),a1        change foregnd colour
  5104.     bsr    addstring
  5105.     addq.l    #1,temp3(a5)        one dir more
  5106. .A    lea    fib_FileName(a5),a1
  5107.     move.l    a1,a0
  5108.     moveq    #-1,d2
  5109.     add.w    indent_count(a5),d2
  5110. .B    addq    #1,d2
  5111.     tst.b    (a0)+
  5112.     bne.s    .B
  5113.     bsr     addstring        print filename
  5114.  
  5115.     tst.l    fib_DirEntryType(a5)
  5116.     bpl.s    .C
  5117. .F    move.l    fib_NumBlocks(a5),d0
  5118.     add.l    d0,temp4(a5)
  5119.     move.l    fib_Size(a5),d0
  5120.     add.l    d0,temp1(a5)        increase total size
  5121.     move.b    #" ",(a2)+
  5122.     moveq    #34,d1
  5123.     sub.w    d2,d1
  5124.     bsr    qdecpr
  5125.     bra.s    prlink
  5126. .C    moveq    #29,d1
  5127.     sub.w    d2,d1
  5128.     bpl.s    .D
  5129.     moveq    #0,d1
  5130. .D    move.b    #" ",(a2)+
  5131.     dbra    d1,.D
  5132.     lea    dirtext(pc),a1
  5133.     bsr    addstring
  5134. prlink    move.b    #" ",(a2)+
  5135.     move.b    #" ",(a2)+
  5136.     move.l    fib_DirEntryType(a5),d0
  5137.     moveq    #-6,d1
  5138.     cmp.l    d1,d0
  5139.     bne.s    .B
  5140.     move.b    #"S",-1(a2)
  5141.     bra.s    .A
  5142. .B    moveq    #4,d1
  5143.     cmp.l    d1,d0
  5144.     bne.s    .C
  5145.     move.b    #"H",-1(a2)
  5146.     bra.s    .A
  5147. .C    moveq    #-4,d1
  5148.     cmp.l    d1,d0
  5149.     bne.s    .A
  5150.     move.b    #"H",-1(a2)
  5151. .A    move.b    #" ",(a2)+
  5152.     addq.l    #1,temp2(a5)
  5153.     move.l    temp2(a5),d0        are we printing wide
  5154.     bpl.s    wpro
  5155.     btst.l    #0,d0
  5156.     beq.s    .F
  5157.     move.b    #LF,(a2)+
  5158. .F    clr.b    (a2)
  5159.     lea    temp2buf(a5),a1
  5160.     bra    pr_string        print string&return and return
  5161.  
  5162. wpro    btst    #29,temp2(a5)
  5163.     beq.s    .E
  5164.     move.l    a2,a0
  5165.     bsr    pr_pro2            print protection V2.0
  5166.     move.b    #" ",(a0)+
  5167.     move.l    a0,a2            (goes to temp2buf)
  5168.     btst    #24,temp2(a5)        protect flag ?
  5169.     bne.s    .E
  5170.     lea    fib_Date(a5),a1
  5171.     lea    -14(sp),sp
  5172.     lea    (sp),a0
  5173.     bsr    convert_time
  5174.     move.l    a2,a1
  5175.     bsr    qprint10
  5176.     move.b    #".",(a1)+
  5177.     bsr    qprint10
  5178.     move.b    #".",(a1)+
  5179.     bsr    qprint10
  5180.     move.b    #" ",(a1)+
  5181.     move.b    #" ",(a1)+
  5182.     bsr    qprint10
  5183.     move.b    #":",(a1)+
  5184.     bsr    qprint10
  5185.     move.b    #":",(a1)+
  5186.     bsr    qprint10
  5187.     move.b    #LF,(a1)+
  5188.     lea    14(sp),sp
  5189.     move.l    a1,a2
  5190. .E    clr.b    (a2)
  5191.     lea    temp2buf(a5),a1
  5192.     bsr    pr_string        print date/time V2.0
  5193.  
  5194.     move.l    d7,d1
  5195.     bsr    CurrentDir        d0=old current dir
  5196.     movem.l    d0/d4-d7/a3-a4,-(sp)
  5197.     move.l    d7,d6
  5198.     btst.l    #28,temp2(a5)
  5199.     beq    fort
  5200.     tst.b    fib_Comment(a5)
  5201.     beq.s    .A
  5202.     bsr    num_spc
  5203.     lea    farb2(pc),a1
  5204.     bsr    addstring
  5205.     move.b    #":",(a2)+
  5206.     clr.b    (a2)
  5207.     lea    temp2buf(a5),a1
  5208.     bsr    pr_string
  5209.     lea    fib_Comment(a5),a1
  5210.     bsr    pr_string        print Comment V2.0
  5211.     lea    farb1(pc),a1
  5212.     bsr    pr_stringlf
  5213.  
  5214. .A    cmp.w    #36,kickver(a5)
  5215.     blo    fort
  5216.     move.l    fib_DirEntryType(a5),d0
  5217.     bpl.s    .F
  5218.     neg.l    d0
  5219. .F    moveq    #4,d1
  5220.     cmp.l    d0,d1
  5221.     bne.s    .G
  5222.     lea    NewPrintBuffer(a5),a2    process hardlinks
  5223.     lea    farb2(pc),a1
  5224.     bsr    addstring
  5225.     lea    pfeil(pc),a1
  5226.     bsr    addstring
  5227.     lea    fib_FileName(a5),a0
  5228.     move.l    a0,d1
  5229.     moveq    #ACCESS_READ,d2
  5230.     jsr    _LVOLock(a6)
  5231.     tst.l    d0
  5232.     beq.s    .C
  5233.     move.l    a2,a0
  5234.     bsr    eval_full_path
  5235.     jsr    _LVOUnLock(a6)
  5236.     bra.s    .B
  5237. .G    moveq    #-6,d0
  5238.     cmp.l    fib_DirEntryType(a5),d0    check whether is softlink
  5239.     bne.s    fort
  5240.     lea    fib_FileName(a5),a2    process softlinks
  5241.     move.l    a2,d1
  5242.     jsr    _LVODeviceProc(a6)
  5243.     move.l    d0,d4
  5244.     beq.s    .C
  5245.     move.l    a2,d3    path (filename)
  5246.     lea    NewPrintBuffer(a5),a2
  5247.     lea    farb2(pc),a1
  5248.     bsr    addstring
  5249.     lea    pfeil(pc),a1
  5250.     bsr    addstring
  5251.     move.l    d4,d1    msgport of device
  5252.     move.l    d6,d2    lock on current dir
  5253.     move.l    a2,d4    buffer
  5254.     moveq    #120,d5    size of buffer
  5255.     jsr    _LVOReadLink(a6)
  5256. .C    bsr    maybeDOSerr
  5257.     beq.s    fort
  5258. .B    lea    NewPrintBuffer(a5),a1
  5259.     bsr    pr_string        ;print softlink V2.3
  5260.     lea    farb1(pc),a1
  5261.     bsr    pr_stringlf
  5262.  
  5263. fort    move.w    temp2(a5),d0    get upper two bytes
  5264.     and.w    #%0000010010010000,d0    copy,delete or join flag
  5265.     beq    .B        no: try protect
  5266.     btst    #25,temp2(a5)
  5267.     bne    .A        not process flag ?
  5268.  
  5269.     btst    #22,temp2+1(a5)        move flag ?
  5270.     beq.s    .E
  5271.     btst    #21,temp2+1(a5)        MOVE !
  5272.     beq.s    .E    need not try to rename
  5273.     tst.l    fib_DirEntryType(a5)
  5274.     bpl.s    .D    delete dir
  5275.     lea    fib_FileName(a5),a0
  5276.     bsr    MoveFile
  5277.     bne    .A
  5278.     bclr    #21,temp2+1(a5)    cannot rename
  5279.  
  5280. .E    btst    #23,temp2+1(a5)        copy flag ?
  5281.     beq.s    .D
  5282.     tst.l    fib_DirEntryType(a5)
  5283.     bpl    .H
  5284.     lea    fib_FileName(a5),a0    COPY !
  5285.     bsr    CopyFileToDir
  5286.     bne    .A        error occured->not delete
  5287.  
  5288. .D    btst    #26,temp2(a5)        delete flag ?
  5289.     beq.s    .C
  5290.     lea    fib_FileName(a5),a0    DELETE !
  5291.     tst.l    fib_DirEntryType(a5)
  5292.     bpl.s    .I    
  5293.     bsr    DoDelete
  5294.     bra.s    .C
  5295. .I    bsr    DoDelete2
  5296.  
  5297. .C    btst    #20,temp2+1(a5)        join flag ?
  5298.     beq.s    .B
  5299.     tst.l    fib_DirEntryType(a5)
  5300.     bpl.s    .H
  5301.     lea    fib_FileName(a5),a0    JOIN !
  5302.     bsr    JoinFile
  5303.  
  5304. .B    btst    #24,temp2(a5)        protect flag ?
  5305.     beq.s    .A
  5306.     move.l    fib_Protection(a5),d2    PROTECT !
  5307.     eor.b    #$0f,d2
  5308.     or.l    temp5(a5),d2
  5309.     and.l    temp6(a5),d2
  5310.     lea    fib_FileName(a5),a0
  5311.     move.l    a0,d1
  5312.     eor.b    #$0f,d2
  5313.     move.l    d2,fib_Protection(a5)
  5314.     jsr    _LVOSetProtection(a6)
  5315.     bsr    maybeDOSerr
  5316.     lea    temp2buf(a5),a2    print new protection
  5317.     lea    pfeil(pc),a1
  5318.     bsr    addstring
  5319.     move.l    a2,a0
  5320.     bsr    pr_pro2
  5321.     move.b    #LF,(a0)+
  5322.     clr.b    (a0)
  5323.     bsr    pr_string    (temp2buf in a1)
  5324.  
  5325.     bra.s    .A
  5326. .H    bsr    pr_lf
  5327. .A    movem.l    (sp)+,d0/d4-d7/a3-a4
  5328.     move.l    d0,d1
  5329.     bsr    CurrentDir
  5330.     rts
  5331.  
  5332. qprint10 move.w    (a0)+,d0    V2.0
  5333. qpr10    ext.l    d0    (also used by more)
  5334.     divu    #10,d0    Value in d0 , Buffer in a1
  5335.     add.b    #"0",d0
  5336.     move.b    d0,(a1)+
  5337.     swap    d0
  5338.     add.b    #"0",d0
  5339.     move.b    d0,(a1)+
  5340.     rts
  5341.  
  5342. num_spc    lea    temp2buf(a5),a2        V2.0
  5343.     move.w    indent_count(a5),d0
  5344.     moveq    #$3f,d1
  5345.     and.l    d1,d0
  5346.     bra.s    .B
  5347. .A    move.b    #" ",(a2)+    the preceding spaces
  5348. .B    dbra    d0,.A
  5349.     rts
  5350.  
  5351. addstring move.b (a1)+,(a2)+
  5352.     bne.s    addstring
  5353.     subq.l    #1,a2
  5354.     rts
  5355.  
  5356. qdecpr    * Number in d0.l , Length in d1.w , adds string to buffer in a2
  5357.     movem.l    d2/d3/a0,-(sp)    ;Prints Decimal Number in (a2)
  5358.     lea    -12(sp),sp
  5359.     move.l    sp,a0
  5360.     move.l    d1,d3
  5361.     moveq    #0,d2
  5362. .A    moveq    #LF,d1
  5363.     bsr    div_32
  5364.     add.b    #$30,d1
  5365.     move.b    d1,(a0)+
  5366.     addq.w    #1,d2
  5367.     tst.l    d0
  5368.     bne.s    .A
  5369.     sub.w    d2,d3
  5370.     subq.w    #1,d3
  5371.     bmi.s    .B
  5372. .D    move.b    #" ",(a2)+
  5373.     dbra    d3,.D
  5374. .B    subq.w    #1,d2
  5375. .C    move.b    -(a0),(a2)+
  5376.     dbra    d2,.C
  5377.     lea    12(sp),sp
  5378.     movem.l    (sp)+,d2/d3/a0
  5379.     rts
  5380.  
  5381. fixsoftlink
  5382.     moveq    #3,d0
  5383.     cmp.l    fib_DirEntryType(a5),d0        is it a softlink ?
  5384.     bne.s    .A
  5385.     move.l    #-6,fib_DirEntryType(a5)    make it look like a file
  5386. .A    rts
  5387.  
  5388. *** CHECK CTRL_C
  5389. ** RETURN NE if ctrl c, EQ if not
  5390. check_c    movem.l    d0-d1/a0-a1/a6,-(sp)    checks if CTRL-C pressed
  5391.     tst.b    break_flag(a5)
  5392.     bne.s    .A
  5393.     moveq    #0,d0
  5394.     moveq    #0,d1
  5395.     move.l    4.w,a6
  5396.     bset    #SIGBREAKB_CTRL_C,d1
  5397.     jsr    _LVOSetSignal(a6)
  5398.     btst    #SIGBREAKB_CTRL_C,d0
  5399.     beq.s    .B
  5400. .A    move.l    dosbase(a5),a6
  5401.     lea    breaktx(pc),a1
  5402.     bsr    pr_string
  5403.     moveq    #1,d0            NE: STOP!!!
  5404.     move.b    d0,break_flag(a5)
  5405.     movem.l    (sp)+,d0-d1/a0-a1/a6
  5406.     rts
  5407. .B    clr.b    break_flag(a5)
  5408.     moveq    #0,d0            EQ: no stop
  5409.     movem.l    (sp)+,d0-d1/a0-a1/a6
  5410.     rts
  5411.  
  5412.  
  5413. *ALLOCATE MEMORY D0=size D1=type
  5414. iwantmem    movem.l d1/a0-a1,-(sp)
  5415.     move.l 4.w,a6
  5416.     jsr _LVOAllocMem(a6)
  5417.     move.l dosbase(a5),a6
  5418.     movem.l (sp)+,d1/a0-a1
  5419.     tst.l    d0
  5420.     rts
  5421. *FREEMEM A1=ptr to mem block D0=size
  5422. givemem    move.l    4.w,a6
  5423.     jsr    _LVOFreeMem(a6)
  5424.     move.l    dosbase(a5),a6
  5425.     rts
  5426.     
  5427.  
  5428. *REMOVE PATH A0-> source A1->destination
  5429. rempath    movem.l d0/a0-a2,-(sp)
  5430. rempath1    move.l a0,a2
  5431. rempath2    move.b (a0)+,d0
  5432.     cmp.b #'/',d0
  5433.     beq.s rempath1
  5434.     cmp.b #':',d0
  5435.     beq.s rempath1
  5436.     tst.b d0
  5437.     bne.s rempath2
  5438.     move.l a2,a0
  5439.     bsr cp_string
  5440.     movem.l (sp)+,d0/a0-a2
  5441.     rts
  5442.  
  5443.  
  5444. ** PRINT STRING (A1) USING indent_count(a5) AS A SPACE INDENT COUNT
  5445. prindent    movem.l    d7/a0-a1,-(sp)
  5446.     move.w    indent_count(a5),d7
  5447.     move.l    a1,a0
  5448.     and.w    #$3f,d7
  5449.     beq.s    .A
  5450.     bra.s    .B
  5451. .C    bsr    pr_space    print d7 spaces
  5452. .B    dbra    d7,.C
  5453.     move.l    a0,a1
  5454. .A    bsr    pr_string
  5455.     movem.l    (sp)+,d7/a0-a1
  5456.     rts
  5457.  
  5458. ** ENTRY A0 pts to parameter.
  5459. ** EXIT D0=lower case char after dash OR 0 if no dash command.
  5460. return_dash_option
  5461.     moveq    #0,d0
  5462.     cmp.b    #'-',(a0)
  5463.     bne.s    .B
  5464. .A    move.b    1(a0),d0
  5465.     cmp.b    #'a',d0
  5466.     blo.s    .B
  5467.     cmp.b    #'z',d0
  5468.     bhi.s    .B
  5469.     sub.b    #$20,d0
  5470. .B    rts
  5471.  
  5472. check_q_r    ;checks for -q, -s or -r (or ALL) options, parm-ptr in a2
  5473.     lea    parm2(a5),a2
  5474.     clr.b    recurs_flag(a5)
  5475.     btst    #FLall,Flags+3(a5)
  5476.     beq.s    .A
  5477.     lea    alltx(pc),a0
  5478.     bsr    LookForOpt
  5479.     bne.s    .A
  5480.     move.b    #1,recurs_flag(a5)
  5481. .A    move.l    a2,a1
  5482.     move.l    (a1),d0
  5483.     beq.s    .E
  5484.     move.l    d0,a0
  5485.     bsr    return_dash_option
  5486.     tst.l    d0
  5487.     beq.s    .E
  5488.     cmp.b    #"R",d0
  5489.     bne.s    .B
  5490.     move.b    #1,recurs_flag(a5)    -r -> recursive
  5491.     bra.s    .G
  5492. .B    cmp.b    #"Q",d0
  5493.     bne.s    .C
  5494.     bset    #30,temp2(a5)        -q -> quick,nosort
  5495.     bra.s    .G
  5496. .C    cmp.b    #"S",d0
  5497.     bne.s    .E
  5498.     bclr    #30,temp2(a5)        -s -> noquick,sort
  5499. .G    lea    4(a1),a0
  5500. .F    move.l    (a0)+,(a1)+
  5501.     bne.s    .F
  5502.     bra.s    .A
  5503. .E    rts
  5504.  
  5505.  
  5506. CurrentDir    ;same as _LVOCurrentDir(a6)
  5507.     move.l    thistask(a5),a0
  5508.     lea    pr_CurrentDir(a0),a0
  5509.     move.l    (a0),d0
  5510.     move.l    d1,(a0)
  5511.     rts
  5512.  
  5513. *************************
  5514. *    DELETE        *    V2.3 new written
  5515. *************************
  5516. deletez    clr.l    temp2(a5)
  5517.     bset    #26,temp2(a5)
  5518.     bsr    check_q_r
  5519.     move.l    (a2),d0
  5520.     beq    too_less_args
  5521.     move.l    d0,a0
  5522.     lea    devicetx(pc),a1
  5523.     bsr    CheckOpt
  5524.     beq    deldevice    format device quick
  5525.     lea    forcetx(pc),a0
  5526.     bsr    LookForOpt    FORCE-flag ?
  5527.     subq.l    #1,d0
  5528.     move.l    d0,temp5(a5)
  5529.     bra    directory2    delete as many files as given
  5530.  
  5531. DoDelete    ;file to delete in a0
  5532.     btst.l    #30,temp2(a5)
  5533.     bne.s    DoDelete2
  5534.     btst.l    #22,temp2+1(a5)    move-> do not ask
  5535.     bne.s    DoDelete2
  5536.     move.l    a0,-(sp)    ASK first
  5537.     move.l    stdin(a5),d1
  5538.     beq.s    DoDelete2
  5539.     lea    yesnotx(pc),a1
  5540.     bsr    pr_string
  5541.     bsr    raw_on
  5542.     lea    temp2buf(a5),a2
  5543.     clr.b    (a2)
  5544.     move.l    a2,d2
  5545.     moveq    #20,d3    read only 1 char
  5546.     jsr    _LVORead(a6)
  5547.     clr.b    1(a2)
  5548.     move.l    a2,a1
  5549.     bsr    pr_string    show it
  5550.     bsr    pr_space
  5551.     bsr    rawh_off
  5552.     move.l    (sp)+,a0
  5553.     or.b    #$20,(a2)
  5554.     cmp.b    #"y",(a2)    yes ?
  5555.     beq.s    DoDelete2
  5556.     cmp.b    #"a",(a2)    all ?
  5557.     bne.s    .A
  5558.     bset    #30,temp2(a5)    set quick flag
  5559.     bra.s    DoDelete2
  5560. .A    cmp.b    #"q",(a2)    quit ?
  5561.     bne.s    .E
  5562.     move.b    #1,break_flag(a5)
  5563. .E    bsr    pr_lf
  5564.     bra.s    DoDeEnd
  5565. DoDelete2
  5566.     move.l    a0,a2
  5567. .E    move.l    a2,d1
  5568.     jsr    _LVODeleteFile(a6)    delete file/dir
  5569.     tst.l    d0
  5570.     bne.s    .B
  5571. .D    jsr    _LVOIoErr(a6)
  5572.     cmp.l    #222,d0        delete-protected ?
  5573.     bne.s    .A
  5574.     tst.l    temp5(a5)    FORCE-flag ?
  5575.     beq.s    .A
  5576.     move.l    a2,d1
  5577.     moveq    #0,d2
  5578.     jsr    _LVOSetProtection(a6)
  5579.     tst.l    d0
  5580.     beq.s    .D
  5581.     bra.s    .E        try again
  5582. .A    btst.l    #22,temp2+1(a5)
  5583.     bne.s    .F        move: do not print lf
  5584.     bsr    pr_lf            error occured
  5585. .F    bsr    pr_DOSerr
  5586.     bra.s    DoDeEnd
  5587. .B    lea    deleteOK(pc),a1    delete successful
  5588.     btst.l    #22,temp2+1(a5)
  5589.     bne.s    DoDeEnd        move: do not print
  5590.     bsr    pr_string
  5591. DoDeEnd    rts
  5592.  
  5593. *************************
  5594. deldevice        ;formats device quick    V2.3
  5595.     bsr    CheckKS
  5596.     move.l    parm3(a5),d1
  5597.     beq    too_less_args
  5598.     move.l    d1,a2
  5599.     moveq    #-2,d2
  5600.     jsr    _LVOLock(a6)    lock on drive
  5601.     move.l    d0,d7
  5602.     beq    DOSerr
  5603.     move.l    d0,d1
  5604.     move.l    a5,d2        get info data into fib
  5605.     jsr    _LVOInfo(a6)
  5606.     tst.l    d0
  5607.     beq    DOSerrUL
  5608.     move.l    d7,d1
  5609.     jsr    _LVOUnLock(a6)
  5610.     lea    formatask(pc),a1
  5611.     bsr    pr_string
  5612.     bsr    rask
  5613.     tst.l    d0
  5614.     beq.s    .A
  5615.     move.l    parm4(a5),d4
  5616.     bne.s    .B
  5617.     move.l    id_VolumeNode(a5),a0
  5618.     add.l    a0,a0
  5619.     add.l    a0,a0
  5620.     move.l    $28(a0),d4    volumename
  5621.     lsl.l    #2,d4
  5622.     addq.l    #1,d4
  5623. .B    move.l    parm5(a5),d0    check for filesystem
  5624.     beq.s    .D
  5625.     lea    ofs_tx(pc),a1
  5626.     move.l    d0,a0
  5627.     moveq    #0,d3
  5628. .E    bsr    CheckOpt
  5629.     bne.s    .F
  5630.     add.l    #"DOS"<<8,d3
  5631.     bra.s    .G
  5632. .F    addq.b    #1,d3
  5633.     cmp.b    #6,d3
  5634.     bne.s    .E
  5635. .D    move.l    id_DiskType(a5),d3    dostype
  5636. .G    move.l    a2,d1
  5637.     moveq    #-1,d2
  5638.     jsr    _LVOInhibit(a6)        disable drive
  5639.     tst.l    d0
  5640.     beq    DOSerr
  5641.     move.l    a2,d1
  5642.     move.l    d4,d2
  5643.     jsr    _LVOFormat(a6)        format it quick !
  5644.     bsr    maybeDOSerr
  5645.     move.l    a2,d1
  5646.     moveq    #0,d2
  5647.     jsr    _LVOInhibit(a6)        enable drive
  5648.     tst.l    d0
  5649.     beq    DOSerr
  5650. .A    moveq    #RETURN_OK,d0
  5651.     rts
  5652.  
  5653. *************************
  5654. *    PROTECT        *    V2.3 new written
  5655. *************************
  5656. protectz
  5657.     clr.l    temp2(a5)
  5658.     bset    #29,temp2(a5)    bit 29=verbose flag
  5659.     bset    #24,temp2(a5)    bit 24=protect flag
  5660.     bset    #30,temp2(a5)    bit 30=quick flag
  5661.     bsr    check_q_r
  5662.     tst.l    (a2)+
  5663.     beq    too_less_args
  5664.     clr.l    temp5(a5)
  5665.     clr.l    temp6(a5)
  5666. .A    move.l    (a2)+,d0
  5667.     beq.s    .D
  5668.     move.l    d0,a0
  5669.     cmp.b    #"+",(a0)    look for add-option
  5670.     bne.s    .B
  5671.     bsr    GetProtMask
  5672.     move.l    d0,temp5(a5)
  5673.     bra.s    .C
  5674. .B    cmp.b    #"-",(a0)    look for sub-option
  5675.     bne.s    .A
  5676.     bsr    GetProtMask
  5677.     move.l    d0,temp6(a5)
  5678. .C    move.l    a2,a0
  5679.     lea    -4(a2),a1
  5680. .E    move.l    (a0)+,(a1)+    delete this parm
  5681.     bne.s    .E
  5682.     subq.l    #4,a2
  5683.     bra.s    .A
  5684.  
  5685. .D    moveq    #-1,d0
  5686.     eor.l    d0,temp6(a5)
  5687.     bra    directory2    jump into dir-lister
  5688.  
  5689.  
  5690. GetProtMask    ;a0=bits-string, d0=bit-mask
  5691.     moveq    #0,d0
  5692.     addq.l    #1,a0
  5693. .B    move.b    (a0)+,d1
  5694.     beq.s    .C
  5695.     moveq    #7,d2
  5696. .A    cmp.b    protflags(pc,d2.w),d1
  5697.     bne.s    .D
  5698.     bset    d2,d0
  5699.     bra.s    .B
  5700. .D    dbra    d2,.A
  5701.     lea    badprotbit(pc),a1
  5702.     bsr    pr_stringlf
  5703.     bra    galactic
  5704. .C    rts
  5705.  
  5706. pr_prot    lea    temp2buf(a5),a0        V2.0
  5707. pr_pro2    moveq    #7,d0
  5708.     move.l    fib_Protection(a5),d1
  5709.     eor.b    #$0f,d1
  5710. .A    move.b    #"-",(a0)+
  5711.     btst    d0,d1
  5712.     beq.s    .B
  5713.     move.b    protflags(pc,d0.w),-1(a0)
  5714. .B    dbra    d0,.A
  5715.     clr.b    (a0)
  5716.     lea    temp2buf(a5),a1
  5717.     rts
  5718.  
  5719. protflags    dc.b    'dewrapsh'
  5720.  
  5721. *************************
  5722. *    JOIN        *    V2.3 new written
  5723. *************************
  5724. joinz    clr.l    temp2(a5)
  5725.     bset    #20,temp2+1(a5)    set join flag
  5726.     bsr    check_q_r
  5727.     clr.l    devproc(a5)
  5728.     clr.l    temp5(a5)    destination file
  5729.     clr.l    temp6(a5)    memory block
  5730.     lea    parm2(a5),a3
  5731.     addq.l    #4,a3
  5732.     tst.l    (a3)+
  5733.     beq    too_less_args    no arg given
  5734. .A    tst.l    (a3)+
  5735.     bne.s    .A
  5736.     move.l    -8(a3),a2    get last parm
  5737.     clr.l    -8(a3)        and remove it
  5738.     move.l    a2,d1
  5739.     move.l    #MODE_READWRITE,d2
  5740.     jsr    _LVOOpen(a6)
  5741.     move.l    d0,temp5(a5)    open output file and store it
  5742.     beq    DOSerr
  5743.     move.l    d0,d1
  5744.     moveq    #0,d2
  5745.     moveq    #1,d3
  5746.     jsr    _LVOSeek(a6)    look for end, no error checking
  5747.     bsr    GetCopyBlock
  5748.     beq    .F
  5749.     move.l    d0,temp6(a5)
  5750.     bsr    directory2    DO COPY !
  5751.     bsr    FreeCopyBlock
  5752. .F    move.l    temp5(a5),d1
  5753.     jsr    _LVOClose(a6)
  5754.     moveq    #RETURN_OK,d0
  5755.     rts
  5756.  
  5757. JoinFile    ;a0=filename, temp5=outfile, temp6=mem block
  5758.     moveq    #0,d4
  5759.     move.l    a0,d1
  5760.     move.l    #MODE_OLDFILE,d2
  5761.     jsr    _LVOOpen(a6)    open input file
  5762.     move.l    d0,d4        d4=input file handle
  5763.     beq    perr3
  5764.     move.l    temp5(a5),d5    d5=output file handle
  5765.     bsr    PerformCopy        Main Stuff !
  5766.     bne.s    .C
  5767.     lea    joinOK(pc),a1        all OK
  5768.     bsr    pr_string
  5769.     moveq    #RETURN_OK,d0
  5770. .C    rts
  5771.  
  5772. *************************
  5773. *    MOVE        *    V2.3
  5774. *************************
  5775. movez    clr.l    temp2(a5)
  5776.     bset    #22,temp2+1(a5)    set move flag
  5777.     bset    #21,temp2+1(a5)    set rename flag
  5778.     bset    #26,temp2(a5)    set delete flag
  5779.     clr.l    temp7(a5)    holds full dest. pathname
  5780.     bra.s    Copy1
  5781.  
  5782. MoveFile    ;Filename in a0
  5783.     move.l    a0,a3
  5784.     move.l    temp7(a5),a0    path
  5785.     move.l    a3,a1        name
  5786.     lea    temp2buf(a5),a2    path+name
  5787.     bsr    addpath
  5788.     move.l    a2,d2
  5789.     move.l    a3,d1
  5790.     jsr    _LVORename(a6)
  5791.     tst.l    d0
  5792.     beq.s    .A
  5793.     lea    moveOK(pc),a1
  5794.     bsr    pr_string
  5795.     moveq    #1,d0
  5796. .A    rts
  5797.  
  5798. *************************
  5799. *    COPY        *    V2.3 new written
  5800. *************************
  5801. copysize    = 50000
  5802. copyz    clr.l    temp2(a5)
  5803. Copy1    bset    #23,temp2+1(a5)    set copy flag
  5804.     bset    #30,temp2(a5)    bit 30=quick flag
  5805.     bsr    check_q_r
  5806.     clr.l    devproc(a5)
  5807.     clr.l    temp5(a5)    destination dir
  5808.     clr.l    temp6(a5)    memory block
  5809.     lea    parm2(a5),a2
  5810.     tst.l    (a2)+
  5811.     beq    too_less_args    *no arg given
  5812.     tst.l    (a2)+
  5813.     bne.s    Copy2
  5814.     lea    null(pc),a2    *one arg -> copy to current dir
  5815.     bra    Copy3b
  5816.  
  5817. Copy2    tst.l    (a2)+
  5818.     bne    Copy3
  5819.     move.l    -8(a2),a0    *two args -> copy to file/dir
  5820.     clr.l    -8(a2)        get it and remove it
  5821.     move.l    a0,a2
  5822.     move.l    parm2(a5),a0
  5823.     bsr    check_wild
  5824.     tst.l    d0
  5825.     beq    Copy3b        wildcards->copy to dir
  5826.     move.l    parm2(a5),d1
  5827.     btst.l    #22,temp2+1(a5)
  5828.     beq.s    .B        move: try to rename
  5829.     move.l    a2,d2
  5830.     jsr    _LVORename(a6)
  5831.     tst.l    d0
  5832.     beq.s    .B        move:    failed
  5833.     move.l    parm2(a5),a1        OK
  5834.     bsr    pr_string
  5835.     bsr    pr_space
  5836.     lea    moveOK(pc),a1
  5837.     bsr    pr_string
  5838.     moveq    #RETURN_OK,d0
  5839.     rts
  5840. .B    move.l    parm2(a5),d1
  5841.     move.l    #MODE_OLDFILE,d2    try to copy file to file:
  5842.     jsr    _LVOOpen(a6)    try to open input file    (d4)
  5843.     move.l    d0,d4
  5844.     beq.s    Copy3b        input not found->maybe a dir
  5845.     move.l    a2,d1
  5846.     move.l    #MODE_NEWFILE,d2
  5847.     jsr    _LVOOpen(a6)    try to open output file (d5)
  5848.     move.l    d0,d5
  5849.     bne.s    .D
  5850.     bsr    closett
  5851.     bra.s    Copy3b
  5852. .D    move.l    parm2(a5),a1
  5853.     bsr    pr_string
  5854.     bsr    pr_space
  5855.     bsr    GetCopyBlock
  5856.     bne.s    .A
  5857.     bsr    closett
  5858.     bra    resi_no_mem
  5859. .A    move.l    thistask(a5),a0
  5860.     move.l    pr_CurrentDir(a0),a3
  5861.     move.l    a3,temp5(a5)
  5862.     bsr    PerformCopy    do copy !
  5863.     move.l    d0,d4
  5864.     bsr    FreeCopyBlock
  5865.     tst.l    d4        error occured ?
  5866.     bne.s    .E
  5867.     btst    #22,temp2+1(a5)        move flag ?
  5868.     beq.s    .C
  5869.     move.l    parm2(a5),a0
  5870.     bsr    DoDelete    move: delete old file
  5871. .C    lea    copyOK(pc),a1        all OK
  5872.     bsr    pr_string
  5873. .E    move.l    d4,d0
  5874.     rts
  5875.  
  5876. Copy3    tst.l    (a2)+        *three or more args -> copy them to dir
  5877.     bne.s    Copy3        look for last parm
  5878.     move.l    -8(a2),a0    get it
  5879.     clr.l    -8(a2)        and remove it
  5880.     move.l    a0,a2
  5881. Copy3b    move.l    a2,d1
  5882.     moveq    #ACCESS_READ,d2
  5883.     jsr    _LVOLock(a6)    try to lock dir
  5884.     move.l    d0,d7
  5885.     bne.s    .B        found
  5886.     jsr    _LVOIoErr(a6)
  5887.     cmp.l    #205,d0        object not found ?
  5888.     beq.s    .C
  5889.     bra    pr_galactic    no
  5890. .C    move.l    a2,d1
  5891.     jsr    _LVOCreateDir(a6)    yes, make dir
  5892.     move.l    d0,d1
  5893.     beq    DOSerr
  5894.     jsr    _LVOUnLock(a6)    unlock and try again
  5895.     move.l    a2,a1
  5896.     bsr    pr_string
  5897.     bsr    pr_space
  5898.     lea    makedirOK(pc),a1
  5899.     bsr    pr_string
  5900.     bra.s    Copy3b
  5901. .B    bsr    fibexam2
  5902.     tst.l    fib_DirEntryType(a5)    file or dir ?
  5903.     bpl.s    .E
  5904.     move.l    d7,d1
  5905.     jsr    _LVOUnLock(a6)    was not a dir
  5906.     move.l    #212,d0
  5907.     bra    pr_galactic
  5908. .E    move.l    d7,temp5(a5)    was a dir: store lock
  5909.     lea    -80(sp),sp
  5910.     move.l    sp,temp7(a5)
  5911.     bsr    AdjustPath    move: get full path
  5912.     move.l    a2,d1
  5913.     jsr    _LVODeviceProc(a6)
  5914.     move.l    d0,devproc(a5)
  5915.     bsr    GetCopyBlock
  5916.     beq    .F
  5917.     bsr    directory2    DO COPY !
  5918.     bsr    FreeCopyBlock
  5919. .F    lea    80(sp),sp    space needed for move
  5920.     move.l    temp5(a5),d1
  5921.     jsr    _LVOUnLock(a6)    unlock dir
  5922.     moveq    #RETURN_OK,d0
  5923.     rts
  5924.  
  5925. GetCopyBlock
  5926.     move.l    #copysize,d0
  5927.     moveq    #1,d1
  5928.     bsr    iwantmem    get memory block
  5929.     move.l    d0,temp6(a5)
  5930.     rts
  5931.  
  5932. FreeCopyBlock
  5933.     move.l    temp6(a5),a1
  5934.     move.l    #copysize,d0
  5935.     bra    givemem        free memory block
  5936.  
  5937. CopyFileToDir    ;a0=filename
  5938. *current path set, destination path in temp5, memory block in temp6
  5939.     moveq    #0,d4
  5940.     moveq    #0,d5
  5941.     move.l    a0,a2
  5942.     move.l    a0,d1
  5943.     move.l    #MODE_OLDFILE,d2
  5944.     jsr    _LVOOpen(a6)    open input file
  5945.     move.l    d0,d4        d4=input file handle
  5946.     move.l    temp5(a5),d1
  5947.     bsr    CurrentDir
  5948.     move.l    d0,a3        a3 holds current dir
  5949.     tst.l    d4
  5950.     beq    perr3        read protected ?
  5951.     move.l    a2,a0
  5952.     lea    temp2buf(a5),a2
  5953.     move.l    a2,a1
  5954.     bsr    rempath
  5955.     move.l    a2,d1
  5956.     move.l    #MODE_NEWFILE,d2
  5957.     jsr    _LVOOpen(a6)    open output file
  5958.     move.l    d0,d5        d5=output file handle
  5959.     move.l    a3,d1
  5960.     bsr    CurrentDir
  5961.     tst.l    d5
  5962.     beq    perr3        already exits/disk full ?
  5963.     bsr    PerformCopy        Main Stuff !
  5964.     bne.s    .C
  5965.     cmp.l    fib_Size(a5),d6
  5966.     beq.s    .B
  5967.     lea    wrongsize(pc),a1    wrong size
  5968.     bsr    pr_string
  5969.     move.l    d6,d0
  5970.     bsr    print10
  5971.     bsr    pr_lf
  5972.     bra.s    .A
  5973. .B    lea    copyOK(pc),a1        all OK
  5974.     bsr    pr_string
  5975. .A    moveq    #RETURN_OK,d0
  5976. .C    rts
  5977.  
  5978. PerformCopy        ;dest. filename in a2, d4,d5:filehandles
  5979.     clr.l    d6        d6 holds filesize
  5980. .A    move.l    d4,d1
  5981.     move.l    temp6(a5),d2
  5982.     move.l    #copysize,d3
  5983.     jsr    _LVORead(a6)    read a block
  5984.     move.l    d0,d3
  5985.     bmi    perr2        read error ?
  5986.     beq.s    recoend
  5987.     move.l    d5,d1
  5988.     move.l    temp6(a5),d2
  5989.     jsr    _LVOWrite(a6)    write as much as read
  5990.     tst.l    d0
  5991.     bmi    perr2        disk full ?
  5992.     cmp.l    d0,d3
  5993.     bne    perr2        disk full ?
  5994.     add.l    d0,d6        sum up size in d6
  5995.     cmp.l    #copysize,d3
  5996.     bne.s    recoend        buffer not filled by Read
  5997.     lea    dot(pc),a1
  5998.     bsr    pr_string    print dots as progress-indicator
  5999.     bsr    check_c        check for CTRL-C break
  6000.     beq.s    .A
  6001. recoend    bsr    closett
  6002. adjust    tst.l    devproc(a5)
  6003.     beq.s    .A
  6004.     move.l    temp5(a5),d1
  6005.     bsr    CurrentDir
  6006.     move.l    d0,a3
  6007.     move.l    a2,d1
  6008.     move.l    fib_Protection(a5),d2
  6009.     beq.s    .D
  6010.     jsr    _LVOSetProtection(a6)    set old protection
  6011.     tst.l    d0
  6012.     beq    perr1
  6013. .D    move.l    a2,d1
  6014.     lea    fib_Comment(a5),a0    copy comment
  6015.     tst.b    (a0)
  6016.     beq.s    .C
  6017.     move.l    a0,d2
  6018.     jsr    _LVOSetComment(a6)
  6019.     tst.l    d0
  6020.     beq    perr1
  6021. .C    bsr    clearArgs        set old date
  6022.     lea    fib_Date(a5),a0
  6023.     move.l    a0,myArg4(a5)
  6024.     move.l    devproc(a5),packettask(a5)
  6025.     move.l    temp5(a5),myArg2(a5)
  6026.     lea    NewPrintBuffer(a5),a1
  6027.     move.l    a1,d2
  6028.     lsr.l    #2,d2
  6029.     move.l    d2,myArg3(a5)
  6030.     addq.l    #1,a1
  6031.     moveq    #-1,d0
  6032. .B    addq.l    #1,d0
  6033.     move.b    (a2)+,(a1)+
  6034.     bne.s    .B
  6035.     move.b    d0,NewPrintBuffer(a5)
  6036.     moveq    #ACTION_SET_DATE,d0
  6037.     move.l    d0,packettype(A5)
  6038.     bsr    sendpacket
  6039.     tst.l    sp_res1(a5)
  6040.     beq    perr1
  6041.     move.l    a3,d1
  6042.     bsr    CurrentDir
  6043. .A    moveq    #RETURN_OK,d0
  6044.     rts
  6045.  
  6046. perr2
  6047. perr3    bsr    closett
  6048. perr1    jsr    _LVOIoErr(a6)
  6049.     cmp.l    #221,d0
  6050.     bne.s    .A
  6051.     move.b    #1,break_flag(a5)    break if disk is full
  6052. .A    bsr    pr_lf
  6053.     bsr    pr_DOSerr
  6054.     move.l    a3,d1
  6055.     bsr    CurrentDir
  6056.     moveq    #RETURN_ERROR,d0
  6057.     rts
  6058.  
  6059. closett    move.l    d4,d1    ;close files in d4 & d5
  6060.     beq.s    .A
  6061.     jsr    _LVOClose(a6)
  6062.     moveq    #0,d4
  6063. .A    btst    #20,temp2+1(a5)    join: do not close outfile
  6064.     bne.s    .C
  6065.     move.l    d5,d1
  6066.     beq.s    .B
  6067.     jsr    _LVOClose(a6)
  6068. .C    moveq    #0,d5
  6069. .B    rts
  6070.  
  6071.  
  6072.  
  6073. *************************************************************
  6074. ** ENTRY A0=name
  6075. ** EXIT  D0=address, D1=size
  6076. readfile    movem.l    d2-d6/a0-a4,-(sp)
  6077.     move.l    a0,d1
  6078.     move.l    a0,a4
  6079.     move.l    #MODE_OLDFILE,d2
  6080.     jsr    _LVOOpen(a6)    try to open it in current dir
  6081.     move.l    d0,d4    d4=handle
  6082.     bne.s    .A
  6083.     moveq    #-1,d1        Don't request
  6084.     bsr    changeWindowPtr
  6085.     lea    paths(pc),a0
  6086.     move.l    a4,a1
  6087.     lea    tempbuf(a5),a2
  6088.     bsr    addpath
  6089.     move.l    a2,d1
  6090.     move.l    #MODE_OLDFILE,d2
  6091.     jsr    _LVOOpen(a6)    try to open it in S: dir
  6092.     move.l    d0,d4
  6093.     beq    readerr
  6094.     moveq    #0,d1        request on
  6095.     bsr    changeWindowPtr
  6096.  
  6097. .A    moveq    #1,d3        open succeded
  6098.     moveq    #0,d2
  6099.     move.l    d4,d1
  6100.     jsr    _LVOSeek(a6)
  6101.     moveq    #-1,d3
  6102.     moveq    #0,d2
  6103.     move.l    d4,d1
  6104.     jsr    _LVOSeek(a6)
  6105.     move.l    d0,d5    d5=size, handles also powerpacked files
  6106.     moveq    #1,d1
  6107.     bsr    iwantmem
  6108.     beq    readerr2
  6109.     move.l    d0,d6    d6=addr
  6110.     move.l    d6,d2
  6111.     move.l    d5,d3
  6112.     move.l    d4,d1
  6113.     jsr    _LVORead(a6)    READ IT
  6114.     tst.l    d0
  6115.     bmi    readerr3
  6116.     move.l    d4,d1
  6117.     jsr    _LVOClose(a6)    close it
  6118.     move.l    d6,d0
  6119.     move.l    d5,d1
  6120.     movem.l    (sp)+,d2-d6/a0-a4
  6121.     rts
  6122. readerr3    move.l    d6,a1
  6123.     move.l    d5,d0
  6124.     bsr    givemem    ;NB won't work correctly if memory fail occurs.
  6125.             ;Will try to print DOS error for this
  6126. readerr2    move.l    d4,d1
  6127.     jsr    _LVOClose(a6)
  6128. readerr        moveq    #0,d1
  6129.     bsr    changeWindowPtr
  6130.     bra    DOSerr
  6131.  
  6132. *****************
  6133. *    MORE    *
  6134. *****************
  6135. morez    tst.l    parm2(a5)
  6136.     beq    too_less_args
  6137.     moveq    #0,d4
  6138.     move.l    parm3(a5),d0
  6139.     beq    .C
  6140.     move.l    d0,a1
  6141.     bsr    convert_ASCII_to_num
  6142.     beq    bad_number_error
  6143.     tst.w    d0
  6144.     beq.s    .C
  6145.     subq.w    #1,d0
  6146.     move.w    d0,d4
  6147.  
  6148. .C    move.l    parm2(a5),a0
  6149.     bsr    readfile
  6150.     moveq    #0,d2
  6151. ViewMore        ;Jump-In to review the buffer
  6152.     move.l    d0,-(sp)    push address
  6153.     move.l    d1,-(sp)    push size
  6154.     bsr    make_screen
  6155.     move.l    (sp)+,d0
  6156.     move.l    (sp)+,a1
  6157.     bsr    givemem
  6158.     moveq    #RETURN_OK,D0
  6159.     RTS
  6160.  
  6161. make_screen    * more main-routine, also used for help
  6162. * Entry: d0=start adress, d1=length, d4=number of lines or 0, d2=lookback
  6163.     movem.l    d0-d2,-(sp)
  6164.     addq.b    #1,noreview_flag(a5)
  6165.     clr.l    temp1(a5)
  6166.     tst.l    ConsoleSwitch(a5)
  6167.     bne.s    .F
  6168.     addq.l    #1,temp1(a5)
  6169.     move.l    thistask(a5),a3
  6170.     move.l    pr_ConsoleTask(a3),ConsoleSwitch(a5)
  6171.     bsr    raw_on
  6172. .F    btst    #FLcutline,Flags+3(a5)
  6173.     beq.s    .G
  6174.     lea    cutontx(pc),a1
  6175.     bsr    pr_string
  6176. .G    tst.w    d4
  6177.     bne.s    .A
  6178.     bsr    GetWinSize
  6179.     move.w    d0,d4
  6180. .A    movem.l    (sp)+,d0-d2
  6181.     move.w    d4,line_count(a5)
  6182.     move.l    d0,d5    d5=start
  6183.     move.l    d0,a4    a4=ptr
  6184.     move.l    d0,a3
  6185.     move.l     d0,d6
  6186.     add.l    d1,d6    d6=end addr
  6187.     tst.l    d2
  6188.     beq.s    mk_screen
  6189.     move.l    d6,a4
  6190.     bra    look_back
  6191. mk_screen
  6192.     lea    clrhide(pc),a1
  6193.     bsr    pr_string
  6194.     move.w    line_count(a5),d2
  6195.     move.l    a4,-(sp)
  6196.     moveq    #0,d0
  6197.     bra.s    .A
  6198. .C    moveq    #1,d0    PRINT SCREEN FULL OF LINES
  6199. .A;    bsr    pr_line
  6200. .B    cmp.l    d6,a4    check against end
  6201.     beq.s    .E
  6202.     move.b    (a4)+,d0
  6203.     cmp.b    #LF,d0
  6204.     bne.s    .B
  6205.     dbra    d2,.C
  6206.     move.l    a4,a3    A3 points to end of page marker    
  6207. .E    move.l    a4,d7    D7 points to end
  6208.     move.l    (sp)+,a4
  6209. ;    bra    waitabit
  6210.  
  6211.     move.l    a4,d2
  6212.     move.l    outhandle(a5),d1
  6213.     beq.s    waitabit
  6214.     move.l    d7,d3
  6215.     sub.l    a4,d3
  6216.     subq.l    #1,d3
  6217.     bmi.s    waitabit    don't print if 0
  6218.     cmp.l    d7,d6
  6219.     bne.s    .D
  6220.     cmp.l    a3,d7
  6221.     beq.s    .D
  6222.     addq.l    #1,d3
  6223. .D    jsr    _LVOWrite(a6)
  6224.  
  6225. waitabit    
  6226.     move.l    stdin(a5),d1
  6227.     beq    cloga
  6228.     lea    tempbytes(a5),a0
  6229.     move.l    a0,d2
  6230.     moveq    #1,d3
  6231.     jsr    _LVORead(a6)        wait for space key
  6232. .A    moveq    #0,d0            clear top bytes
  6233.     move.b    tempbytes(a5),d0    test byte of input line
  6234.     cmp.b    #$9b,d0
  6235.     beq.s    waitabit        CSI ? Try again !
  6236. tastes    cmp.b    #'a',d0
  6237. ;    blo.s    go_upper
  6238. ;    sub.b    #$20,d0
  6239.  
  6240. go_upper    cmp.b    #$42,d0        cursor down ?
  6241.     beq.s    .G
  6242.     cmp.b    #"2",d0
  6243.     bne.s    ck_up
  6244. .G    cmp.l    d7,d6
  6245.     beq    waitabit
  6246.     lea    scroll_up_tx(pc),a1    SCROLL UP ONE LINE,
  6247.     bsr    pr_string    SEND CURSOR TO START OF LINE
  6248. .B    cmp.l    d6,a4    advance one line
  6249.     beq.s    .C
  6250.     move.b    (a4)+,d0
  6251.     cmp.b    #LF,d0
  6252.     bne.s    .B
  6253. .C    cmp.l    d6,a3    move a3 down one line too
  6254.     beq.s    .D
  6255.     move.b    (a3)+,d0
  6256.     cmp.b    #LF,d0
  6257.     bne.s    .C
  6258. .D    move.l    a4,-(sp)
  6259.     move.l    d7,a4
  6260. ;    cmp.l    d7,d6
  6261. ;    beq.s    .A
  6262.     moveq    #0,d0
  6263.     bsr    pr_line    print line from d7
  6264. .A    cmp.l    d6,a4    advance D7 one line
  6265.     beq.s    .E
  6266.     move.b    (a4)+,d0
  6267.     cmp.b    #LF,d0
  6268.     bne.s    .A
  6269. .E    move.l    a4,d7
  6270.     move.l    (sp)+,a4
  6271.     bra    waitabit
  6272.  
  6273. ck_up    cmp.b    #$41,d0        V2.0    cursor up ?
  6274.     beq.s    .G
  6275.     cmp.b    #"8",d0
  6276.     bne.s    ck_fwd
  6277. .G    cmp.l    d5,a4
  6278.     beq    waitabit
  6279.     lea    scroll_down_tx(pc),a1    SCROLL DOWN ONE LINE,
  6280.     bsr    pr_string    SEND CURSOR TO TOP LEFT
  6281.     cmp.l    d5,a4
  6282.     bls.s    .E
  6283.     subq.l    #1,a4
  6284. .B    cmp.l    d5,a4
  6285.     beq.s    .A
  6286.     cmp.b    #LF,-(a4)
  6287.     bne.s    .B
  6288.     addq.l    #1,a4
  6289. .A    moveq    #0,d0
  6290.     bsr    pr_line
  6291. .E    move.l    d7,a3
  6292.     cmp.l    d5,a3
  6293.     beq.s    .C
  6294.     subq.l    #1,a3
  6295. .D    cmp.l    d5,a3
  6296.     beq.s    .C
  6297.     cmp.b    #LF,-(a3)
  6298.     bne.s    .D
  6299.     addq.l    #1,a3
  6300. .C    move.l    a3,d7
  6301.     lea    temp2buf(a5),a1
  6302.     move.b    #$9b,(a1)+
  6303.     move.w    line_count(a5),d0
  6304.     addq.w    #1,d0
  6305.     bsr    qpr10
  6306.     move.b    #"H",(a1)+
  6307.     clr.b    (a1)
  6308.     lea    temp2buf(a5),a1
  6309.     bsr    pr_string    CURSOR some lines down
  6310.     bra    waitabit
  6311.  
  6312. ck_fwd    cmp.b    #$43,d0            cursor right ?
  6313.     beq.s    .A
  6314.     cmp.b    #"3",d0
  6315.     beq.s    .A
  6316.     cmp.b    #" ",d0
  6317.     bne.s    ck_top
  6318. .A    cmp.l    d7,d6        one page forward
  6319.     beq    waitabit
  6320.     move.l    a3,a4
  6321.     bra    mk_screen
  6322. ck_top    cmp.b    #$54,d0            shift cursor up ?
  6323.     beq.s    .A
  6324.     cmp.b    #"7",d0
  6325.     bne.s    ck_bot
  6326. .A    cmp.l    d5,a4        start of text
  6327.     beq    waitabit
  6328.     move.l    d5,a4
  6329.     bra    mk_screen
  6330. ck_bot    cmp.b    #$53,d0            shift cursor down ?
  6331.     beq.s    .A
  6332.     cmp.b    #"1",d0
  6333.     bne.s    ck_back
  6334. .A    cmp.l    a3,d6        end of text
  6335.     beq    waitabit
  6336.     move.l    d6,a4
  6337.     bra.s    look_back
  6338. ck_back    cmp.b    #$44,d0            cursor left ?
  6339.     beq.s    .A
  6340.     cmp.b    #"9",d0
  6341.     beq.s    .A
  6342.     cmp.b    #8,d0
  6343.     bne.s    ck_skey
  6344. .A    cmp.l    d5,a4        one page back
  6345.     beq    waitabit
  6346. look_back
  6347.     move.w    line_count(a5),d1
  6348.     addq.w    #1,d1
  6349. mlook2    cmp.l    d5,a4    check against start
  6350.     beq.s    .E
  6351.     move.b    -(a4),d0
  6352.     cmp.b    #LF,d0
  6353.     bne.s    mlook2
  6354.     dbra    d1,mlook2
  6355.     lea    1(a4),a4
  6356. .E    bra    mk_screen
  6357.  
  6358. ck_skey    cmp.b    #"s",d0        V2.0    search string ?
  6359.     bne.s    ck_jkey
  6360.     bsr    raw_off
  6361.     lea    msearch(pc),a1
  6362.     bsr    pr_string
  6363.     lea    tempbuf(a5),a2
  6364.     move.b    (a2),d4        save first char
  6365.     move.l    a2,d2
  6366.     moveq    #120,d3
  6367.     move.l    stdin(a5),d1
  6368.     beq.s    .A
  6369.     jsr    _LVORead(a6)
  6370.     tst.l    d0
  6371.     bmi.s    .A
  6372.     move.l    a2,a1
  6373.     add.l    d0,a2
  6374.     subq.l    #1,a2
  6375.     move.b    d4,(a2)
  6376.     cmp.l    a1,a2        just pressed return ?
  6377.     beq.s    .B
  6378.     clr.b    (a2)    no
  6379. .B    move.l    d5,a3
  6380.     move.l    a4,a0
  6381.     bsr    find_end_of_line
  6382.     move.l    a0,a2
  6383.     move.l    d6,a0
  6384.     bsr    searchSTR
  6385.     cmp.b    #LF,d0
  6386.     bne.s    .A
  6387.     move.l    a1,a4    set begin of line on top
  6388.     bra.s    .C
  6389. .A    bsr    DisplayBeep
  6390. .C    bsr    raw_on
  6391.     bra    mk_screen
  6392.  
  6393. ck_jkey    cmp.b    #"j",d0        V2.3    jump to % ?
  6394.     bne.s    ck_wkey
  6395.     bsr    raw_off
  6396.     lea    mjump(pc),a1
  6397.     bsr    pr_string
  6398.     lea    tempbuf(a5),a2
  6399.     move.l    a2,d2
  6400.     moveq    #120,d3
  6401.     move.l    stdin(a5),d1
  6402.     beq.s    .A
  6403.     jsr    _LVORead(a6)
  6404.     tst.l    d0
  6405.     bmi.s    .A
  6406.     move.l    a2,a1
  6407.     add.l    d0,a2
  6408.     subq.l    #1,a2
  6409.     cmp.l    a1,a2        just pressed return ?
  6410.     beq.s    .A
  6411.     clr.b    (a2)    no
  6412.     bsr    convert_ASCII_to_num
  6413.     beq.s    .A
  6414.     moveq    #100,d1
  6415.     cmp.l    d1,d0
  6416.     bhi.s    .A
  6417.     move.l    d6,d1
  6418.     sub.l    d5,d1    calc % of size
  6419.     bsr    mult_32x32
  6420.     moveq    #100,d1
  6421.     bsr    div_32
  6422.     move.l    d5,a4
  6423.     add.l    d0,a4    new pointer
  6424.     bsr    raw_on
  6425.     moveq    #0,d1
  6426.     bra    mlook2    search begin of line
  6427. .A    bsr    raw_on
  6428.     bra    mk_screen
  6429.  
  6430. ck_wkey    cmp.b    #"w",d0        V2.3    write text to file (or print) ?
  6431.     bne.s    ck_hkey
  6432.     bsr    raw_off
  6433.     lea    mwrite(pc),a1
  6434.     bsr    pr_string
  6435.     lea    tempbuf(a5),a2
  6436.     move.l    a2,d2
  6437.     moveq    #120,d3
  6438.     move.l    stdin(a5),d1
  6439.     beq.s    .C
  6440.     jsr    _LVORead(a6)
  6441.     move.l    a2,a1
  6442.     add.l    d0,a2
  6443.     subq.l    #1,a2
  6444.     clr.b    (a2)        null-end
  6445.     cmp.l    a1,a2        just pressed return ?
  6446.     beq.s    .C        yes,quit
  6447.     move.l    a1,d1
  6448.     move.l    #MODE_NEWFILE,d2
  6449.     jsr    _LVOOpen(a6)
  6450.     move.l    d0,d4
  6451.     beq.s    .C
  6452.     move.l    d4,d1
  6453.     move.l    d5,d2
  6454.     move.l    d6,d3
  6455.     sub.l    d2,d3
  6456.     jsr    _LVOWrite(a6)
  6457.     move.l    d4,d1
  6458.     jsr    _LVOClose(a6)
  6459. .C    bsr    raw_on
  6460.     bra    mk_screen
  6461.  
  6462. ck_hkey    cmp.b    #"h",d0        V2.3    help info ?
  6463.     beq.s    .A
  6464.     cmp.b    #$3f,d0        help key ?
  6465.     bne.s    ck_rkey
  6466. .A    move.l    d6,d2
  6467.     sub.l    d5,d2
  6468.     move.l    d2,-(sp)
  6469.     move.l    a4,d0
  6470.     sub.l    d5,d0
  6471.     moveq    #100,d1
  6472.     bsr    mult_32x32
  6473.     move.l    d2,d1
  6474.     bsr    div_32
  6475.     move.w    d0,-(sp)
  6476.     move.l    sp,a1
  6477.     lea    helpmor(pc),a0
  6478.     bsr    new_print
  6479.     addq.l    #6,sp
  6480.     bra    waitabit
  6481.  
  6482. ck_rkey    cmp.b    #"r",d0        V2.3    resized window ?
  6483.     bne.s    unknown_key
  6484.     bsr    GetWinSize
  6485.     move.w    d0,line_count(a5)
  6486.     bra    mk_screen
  6487.  
  6488. unknown_key
  6489.     btst    #FLcutline,Flags+3(a5)    unknown key to exit !
  6490.     beq.s    .G
  6491.     lea    cutofftx(pc),a1
  6492.     bsr    pr_string
  6493. .G    lea    show_cursor(pc),a1
  6494.     bsr    pr_stringlf
  6495.     tst.l    temp1(a5)
  6496.     beq.s    .F
  6497.     bsr    raw_off
  6498.     clr.l    ConsoleSwitch(a5)
  6499. .F    clr.b    noreview_flag(a5)
  6500.     moveq    #RETURN_OK,d0
  6501.     rts
  6502.  
  6503. find_end_of_line
  6504. .B    cmp.l    d6,a0    check against end
  6505.     bhs.s    .A
  6506.     move.b    (a0)+,d0
  6507.     cmp.b    #LF,d0
  6508.     bne.s    .B
  6509.     lea    -1(a0),a0
  6510. .A    rts
  6511.  
  6512. ** PRINT STRING AT A4 ENDING IN LF
  6513. pr_line    movem.l    d0-d4/a0,-(sp)
  6514.     move.l    d0,d4
  6515.     move.l    a4,d2
  6516.     move.l    outhandle(a5),d1
  6517.     beq.s    .C
  6518.     move.l    a4,a0
  6519.     bsr    find_end_of_line
  6520.     sub.l    a4,a0
  6521.     move.l    a0,d3
  6522.     tst.l    d4
  6523.     beq.s    .A
  6524.     subq.l    #1,d2
  6525.     addq.l    #1,d3
  6526. .A    tst.l    d3
  6527.     beq.s    .C    don't print if 0
  6528.     jsr    _LVOWrite(a6)
  6529. .C    movem.l    (sp)+,d0-d4/a0
  6530.     rts
  6531.  
  6532. GetWinSize
  6533.     move.l    a2,-(sp)
  6534.     lea    askforsize(pc),a1
  6535.     bsr    pr_string
  6536. .B    move.l    stdin(a5),d1
  6537.     beq    cloga
  6538.     lea    tempbuf(a5),a2
  6539.     move.l    a2,d2
  6540.     moveq    #100,d3
  6541.     jsr    _LVORead(a6)    get size of window
  6542.     add.l    d0,a2
  6543.     cmp.b    #"r",-(a2)
  6544.     bne.s    .B
  6545.     moveq    #1,d1
  6546. .C    cmp.b    #";",-(a2)
  6547.     bne.s    .C
  6548.     dbra    d1,.C
  6549.     addq.l    #1,a2
  6550.     move.l    a2,a1
  6551.     bsr    convert_ASCII_to_num
  6552.     tst.l    d0
  6553.     beq.s    .D
  6554.     bpl.s    .E
  6555. .D    moveq    #10,d0
  6556. .E    subq.w    #1,d0
  6557.     move.l    (sp)+,a2
  6558.     rts
  6559.  
  6560. *****************
  6561. *    TYPE    *        Type out ASCII file command    
  6562. *****************
  6563. typez    tst.l    parm2(a5)
  6564.     beq    too_less_args
  6565.     move.l    parm2(a5),a0
  6566.     bsr    readfile
  6567.     bsr    rawh_off    MAKE SURE YOU CAN PRESS SPACE TO HOLD IT
  6568.     move.l    d0,-(sp)    push address
  6569.     move.l    d1,-(sp)    push size
  6570.     move.l    d0,a4    a4=ptr
  6571.     move.l     d0,d6
  6572.     add.l    d1,d6    d6=end addr
  6573. next_scr    bsr    pr_screen
  6574. freef1    move.l    (sp)+,d0
  6575.     move.l    (sp)+,a1
  6576.     bsr    givemem
  6577.     moveq    #RETURN_OK,D0
  6578.     RTS
  6579.  
  6580. ** ENTRY D6=end of file A4=current pos
  6581. pr_screen    bsr    check_c
  6582.     bne    type_break
  6583.     moveq    #0,d0
  6584.     bsr    pr_line
  6585.     bsr    pr_lf
  6586. .B    cmp.l    d6,a4    check against end
  6587.     bhs.s    type_break
  6588.     move.b    (a4)+,d0
  6589.     cmp.b    #LF,d0
  6590.     bne.s    .B
  6591.     bra.s    pr_screen
  6592. type_break
  6593.     moveq    #RETURN_OK,D0
  6594.     rts
  6595.  
  6596. ***********************
  6597. * EXECUTE SCRIPT FILE *
  6598. ***********************
  6599. executez    tst.l    parm2(a5)
  6600.     beq    too_less_args
  6601.     bsr    fixpam2
  6602. xz2    bsr    readfile    A0 pts to filename
  6603.     move.l    d0,a0
  6604.     cmp.l    #$000003f3,(a0)    is it executable ?
  6605.     beq.s    exerr
  6606.     addq.l    #4,sp        kill return address
  6607. xz3    move.l    d0,a0
  6608.     cmp.w    #"/*",(a0)
  6609.     beq.s    xrexx
  6610.     move.l    d1,scsize(a5)
  6611.     move.l    d0,scaddr(a5)
  6612.     move.l    d0,scptr(a5)
  6613.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  6614.     clr.b    mult_comm_flag(a5)
  6615.     bra    chorus
  6616. exerr    moveq    #RETURN_ERROR,d0
  6617.     rts
  6618. xrexx    move.l    d0,a1        execute AREXX-script
  6619.     move.l    d1,d0
  6620.     bsr    givemem        kill script
  6621.     lea    CLIbuf(a5),a0
  6622.     move.l    parm1(a5),d0
  6623.     beq.s    .A
  6624.     move.l    d0,a1
  6625. .B    move.b    (a1)+,(a0)+    copy rexx-file to CLIbuf
  6626.     bne.s    .B
  6627. .A    lea    rexxtx(pc),a1
  6628.     move.l    a1,parm1(a5)
  6629.     bra    notfound    execute archie3
  6630.  
  6631. *****************
  6632. *    ECHO    *
  6633. *****************
  6634. echoz    lea    parm2(a5),a3
  6635.     move.l    (a3)+,d0
  6636.     beq.s    echo3
  6637.     bra.s    echo5
  6638. echo2    move.l    (a3)+,d0
  6639.     bne.s    echo4
  6640. echo3    moveq    #RETURN_OK,d0
  6641.     rts
  6642. echo4    bsr    pr_space
  6643. echo5    move.l    d0,a0
  6644.     move.l    a0,a1
  6645.     move.l    a0,a2
  6646.     bra.s    .C
  6647. .B    move.b    d0,(a2)+
  6648. .C    move.b    (a0)+,d0
  6649.     beq.s    .A
  6650.     cmp.b    #$5c,d0 ;\    Ignore Specialchar
  6651.     bne.s    .D
  6652.     move.b    (a0)+,d0
  6653.     bra.s    .B
  6654. .D    cmp.b    #'^',d0        ^-Character
  6655.     bne.s    .B
  6656.     move.b    (a0)+,d0
  6657.     cmp.b    #"*",d0
  6658.     bne.s    .G
  6659.     move.b    #$9b,d0
  6660.     bra.s    .B
  6661. .G    cmp.b    #"$",d0        Number given ?
  6662.     beq.s    .F
  6663.     cmp.b    #"0",d0
  6664.     blo.s    .E
  6665.     cmp.b    #"9",d0
  6666.     bhi.s    .E
  6667. .F    subq.l    #1,a0
  6668.     movem.l    d1/d2/a1,-(sp)
  6669.     move.l    a0,a1
  6670.     bsr    convert_ASCII_to_num
  6671.     lea    -1(a1),a0
  6672.     movem.l    (sp)+,d1/d2/a1
  6673.     cmp.b    #".",(a0)
  6674.     bne.s    .B
  6675.     addq.l    #1,a0
  6676.     bra.s    .B        Number was given
  6677. .E    and.b    #$3f,d0        Control Char
  6678.     bra.s    .B
  6679. .A    clr.b    (a2)+
  6680.     bsr    pr_string
  6681.     bra    echo2
  6682.  
  6683. *****************
  6684. *    CLS    *
  6685. *****************
  6686. clsz    lea    clstx(pc),a1
  6687.     bsr    pr_string
  6688.     moveq    #RETURN_OK,d0
  6689.     rts
  6690.  
  6691. ** MEM INFO :RETURN 3 LONGWORDS AT A0 -> FREE CHIP,FAST,TOTAL
  6692. memory_info
  6693.     movem.l    a0-a2/a6,-(sp)
  6694.     move.l    a0,a2
  6695.     move.l    4.w,a6
  6696.     jsr    _LVOForbid(a6)    ; don't let 'em change while we ask
  6697.     move.l    #MEMF_CHIP,d1    ; ok, check free chip
  6698.     jsr    _LVOAvailMem(a6)    ; ask system how much there is
  6699.     move.l    d0,(a2)
  6700.     move.l    #MEMF_FAST,d1    ; check fast mem avail
  6701.     jsr    _LVOAvailMem(a6)
  6702.     move.l    d0,4(a2)
  6703.     move.l    #MEMF_PUBLIC,d1     ; get all available memory
  6704.     jsr    _LVOAvailMem(a6)
  6705.     move.l    d0,8(a2)
  6706.     jsr    _LVOPermit(a6)
  6707.     movem.l    (sp)+,a0-a2/a6
  6708.     rts
  6709.  
  6710. *****************
  6711. *    AVAIL    *
  6712. *****************
  6713. availz    tst.l    parm2(a5)
  6714.     beq.s    .A
  6715.     move.l    parm2(a5),a0
  6716.     bsr    return_dash_option
  6717.     cmp.b    #'C',d0
  6718.     bne.s    .A
  6719.     bsr    giveman        free some memory
  6720.     move.l    4.w,a6
  6721.     moveq    #-1,d0        Free mem
  6722.     move.l    #$00002711,d1    MAGIC NUMBER (from FIDO-net)
  6723.     jsr    _LVOAllocMem(a6)
  6724.     jsr    _LVOForbid(a6)
  6725.     movea.l    a6,a0
  6726.     moveq    #72,d0
  6727.     add.l    d0,a0
  6728.     moveq    #15,d0        free 16 interrupts
  6729.     moveq    #-1,d1
  6730.     moveq    #12,d2
  6731. .B    add.l    d2,a0
  6732.     cmp.l    (a0),d1
  6733.     bne.s    .C
  6734.     cmp.l    4(a0),d1
  6735.     bne.s    .C
  6736.     clr.l    (a0)
  6737.     clr.l    4(a0)
  6738. .C    dbra    d0,.B
  6739.     jsr    _LVOPermit(a6)
  6740.     move.l    dosbase(a5),a6
  6741. .A    lea    -12(sp),sp    show mem
  6742.     lea    (sp),a0
  6743.     bsr    memory_info
  6744.     move.l    a0,a1
  6745.     lea    memess(pc),a0
  6746.     bsr    new_print    show memory
  6747.     lea    12(sp),sp
  6748.     moveq    #RETURN_OK,d0
  6749.     rts
  6750.  
  6751.  
  6752. * ALTER WINDOW PTR FOR THIS PROCESS. USE TO DISABLE REQUESTERS POPPING UP.
  6753. * ENTRY D1=0 (NORMAL)  D1=-1 (SUBNORMAL, no requesters).
  6754. changeWindowPtr
  6755.     movem.l    d1/a0,-(sp)
  6756.     tst.l    d1
  6757.     bne.s    .A
  6758.     move.l    window_old(a5),d1
  6759. .A    move.l    thistask(a5),a0
  6760.     move.l    d1,pr_WindowPtr(a0)
  6761.     movem.l    (sp)+,d1/a0
  6762.     rts
  6763.  
  6764. raw_on    movem.l    d6/d7,-(sp)    switch console to raw mode
  6765.     btst    #FLhide,Flags+2(a5)
  6766.     beq.s    .A
  6767.     lea    show_cursor(pc),a1
  6768.     bsr    pr_string
  6769. .A    moveq    #-1,d6
  6770.     bra.s    raw_switch
  6771.  
  6772. rawh_off    movem.l    d6/d7,-(sp)    like raw_off,but hides the cursor
  6773.     btst    #FLhide,Flags+2(a5)
  6774.     beq.s    .A
  6775.     lea    hide_cursor(pc),a1
  6776.     bsr    pr_string
  6777. .A    moveq    #0,d6
  6778.     bra.s    raw_switch
  6779.  
  6780. raw_off    movem.l    d6/d7,-(sp)    switch console to normal mode
  6781.     moveq    #0,d6
  6782. ;    bra.s    raw_switch
  6783.  
  6784. *WINDOW TYPE CHANGER    
  6785. raw_switch
  6786.     move.l    ConsoleSwitch(a5),d7
  6787.     beq.s    .A
  6788.     move.l    d7,packettask(a5)
  6789.     bsr    clearArgs
  6790.     move.l    #ACTION_SCREEN_MODE,packettype(a5)
  6791.     move.l    d6,myArg1(a5)
  6792.     bsr    sendpacket
  6793. .A    movem.l    (sp)+,d6/d7
  6794.     rts
  6795.  
  6796. clearArgs movem.l    d0/a0,-(sp)
  6797.     lea    sp_node(a5),a0
  6798.     moveq    #16,d0    ;68bytes
  6799. .A    clr.l    (a0)+
  6800.     dbra    d0,.A
  6801.     movem.l    (sp)+,d0/a0
  6802.     rts
  6803.     
  6804. ** ENTRY Uses myArg1-myArg7, and packettask, packettype
  6805. sendpacket    tst.l    packettask(a5)
  6806.     beq.s    .A
  6807.     movem.l    d0-d1/a0-a2,-(sp)    V2.0 (new written)
  6808.     bsr    sendpacket2
  6809.     move.l    a2,a0
  6810.     jsr    _LVOWaitPort(a6)
  6811.     move.l    a2,a0
  6812.     jsr    _LVOGetMsg(a6)
  6813.     move.l    dosbase(a5),a6
  6814.     movem.l    (sp)+,d0-d1/a0-a2
  6815. .A    rts
  6816.  
  6817. sendpacket2    ;used by sendpacket and get_one_char
  6818.     move.l    4.w,a6
  6819.     move.b    #5,LN_TYPE+sp_node(a5)    message
  6820.     move.l    thistask(a5),a2
  6821.     lea    pr_MsgPort(a2),a2    Process-MsgPort !
  6822.     move.l    a2,sp_reply(a5)        Replyport
  6823.     move.l    a2,sp_port(a5)
  6824.     move.w    #dp_SIZEOF+4,sp_length(a5)
  6825.     lea    sp_link(a5),a0
  6826. ;    move.l    a0,sp_ptr(a5)
  6827.     move.l    a0,LN_NAME+sp_node(a5)    points to link
  6828.     lea    sp_node(a5),a1
  6829.     move.l    a1,sp_link(a5)        linked to itself
  6830.     move.l    packettask(a5),a0
  6831.     jsr    _LVOPutMsg(a6)
  6832.     rts
  6833.  
  6834. *************************
  6835. *    RELABEL     *
  6836. *************************
  6837. relabelz    tst.l    parm3(a5)
  6838.     beq    too_less_args
  6839.     move.l    parm2(a5),a0
  6840.     bsr    check_for_colon
  6841.     bne    no_col
  6842. .D    move.l    parm2(a5),d1    PARM2=DF0: etc
  6843.     jsr    _LVODeviceProc(a6)
  6844.     tst.l    d0
  6845.     beq    DOSerr
  6846.     move.l    d0,packettask(a5)
  6847.     move.l    #256,d0
  6848.     moveq    #1,d1
  6849.     bsr    iwantmem        ASSUME GETS 256 BYTES
  6850.     move.l    d0,a2        A2=destination
  6851.     lsr.l    #2,d0
  6852.     bsr    clearArgs
  6853.     move.l    d0,myArg1(a5)    BPTR to my string
  6854.     move.l    parm3(a5),a0    NewName
  6855.     lea    1(a2),a1        A1=after count
  6856.     moveq    #0,d0
  6857. .A    move.b    (a0)+,(a1)+
  6858.     addq.l    #1,d0
  6859.     cmp.b    #':',(a0)        ALLOW FOR IDIOTS WHO PUT : ON END
  6860.     beq.s    .C
  6861.     tst.b    (a0)
  6862.     bne.s    .A
  6863. .C    clr.b    (a1)
  6864.     move.b    d0,(a2)
  6865.     moveq    #ACTION_RENAME_DISK,d0
  6866.     move.l    d0,packettype(a5)    TYPE=RENAME_DISK
  6867.     bsr    sendpacket
  6868.     move.l    a2,a1
  6869.     move.l    #256,d0
  6870.     bsr    givemem
  6871.     bsr    changedisk    ;(moved to dc)
  6872. *    bsr    eval_CD        -IS MORE ELEGANT IF I LEAVE OUT.
  6873.     moveq    #RETURN_OK,d0    USER WILL HAVE TO TYPE CD TO CHANGE
  6874.     rts            PROPER.
  6875.  
  6876. *************************
  6877. *    ADDBUFFERS    *
  6878. *************************
  6879. addbuffersz
  6880.     cmp.w    #36,kickver(a5)
  6881.     blo.s    .A
  6882.     move.l    parm2(a5),d3
  6883.     beq    too_less_args
  6884.     move.l    parm3(a5),d0
  6885.     beq.s    .B
  6886.     move.l    d0,a1
  6887.     bsr    convert_ASCII_to_num
  6888.     beq    bad_number_error
  6889. .B    move.l    d3,d1
  6890.     move.l    d0,d2
  6891.     jsr    _LVOAddBuffers(a6)
  6892.     tst.l    d0
  6893.     beq    DOSerr
  6894.     moveq    #-1,d1
  6895.     cmp.l    d1,d0
  6896.     bne.s    .C
  6897.     jsr    _LVOIoErr(a6)
  6898. .C    move.l    d0,-(sp)
  6899.     move.l    d3,-(sp)
  6900.     lea    (sp),a1
  6901.     lea    addbufftx(pc),a0
  6902.     bsr    new_print
  6903.     addq.l    #8,sp
  6904.     bra.s    .D
  6905.  
  6906. .A    tst.l    parm3(a5)
  6907.     beq    too_less_args
  6908.     bsr    clearArgs
  6909.     move.l    parm3(a5),a1
  6910.     bsr    convert_ASCII_to_num
  6911.     beq    bad_number_error
  6912.     cmp.l    #32767,d0
  6913.     bhi    bad_number_error
  6914.     move.l    d0,myArg1(a5)
  6915.     move.l    parm2(a5),d1    PARM2=DF0: etc
  6916.     jsr    _LVODeviceProc(a6)
  6917.     tst.l    d0
  6918.     beq    DOSerr
  6919.     move.l    d0,packettask(a5)
  6920.     moveq    #ACTION_MORE_CACHE,d0
  6921.     move.l    d0,packettype(A5)
  6922.     bsr    sendpacket
  6923.     bsr    PKTerr
  6924. .D    moveq    #RETURN_OK,d0
  6925.     rts
  6926.  
  6927. *************************
  6928. *    DIE-Handler    *
  6929. *************************
  6930. diez    move.l    parm2(a5),d1
  6931.     beq    too_less_args
  6932.     move.l    d1,a0
  6933.     bsr    check_for_colon
  6934.     bne.s    .A
  6935.     bsr    clearArgs    ;kill filesystemhandler
  6936.     jsr    _LVODeviceProc(a6)    PARM2=DF0: etc
  6937.     tst.l    d0
  6938.     beq    DOSerr
  6939.     move.l    d0,packettask(a5)
  6940.     moveq    #ACTION_DIE,d0
  6941.     move.l    d0,packettype(A5)
  6942.     bsr    sendpacket
  6943.     bsr    PKTerr
  6944. .B    moveq    #RETURN_OK,d0
  6945.     rts
  6946.  
  6947. .A    move.l    d1,a2
  6948.     bsr    findtsk
  6949.     beq.s    .B
  6950.     move.l    pr_CIS(a0),d2
  6951.     move.l    pr_COS(a0),d3
  6952.     move.l    a0,a1
  6953.     move.l    4.w,a6
  6954.     jsr    _LVORemTask(a6)
  6955.     move.l    dosbase(a5),a6
  6956.     move.l    d2,d1
  6957.     beq.s    .C
  6958.     jsr    _LVOClose(a6)
  6959. .C    move.l    d3,d1
  6960.     beq.s    .D
  6961.     jsr    _LVOClose(a6)
  6962. .D    bra.s    .B
  6963.  
  6964. *************************
  6965. *    SETDATE        *
  6966. *************************
  6967. setdatez tst.l    parm2(a5)
  6968.     beq    too_less_args
  6969.     move.l    parm2(a5),a2
  6970.     bsr    clearArgs
  6971.     lea    date_mark(a5),a0
  6972.     lea    (a0),a3
  6973.     move.l    a0,myArg4(a5)    ;APTR datestamp
  6974.     bsr    get_time
  6975.     tst.l    parm3(a5)
  6976.     beq    nospda
  6977.     move.l    a2,d1
  6978.     moveq    #ACCESS_READ,d2
  6979.     jsr    _LVOLock(a6)
  6980.     move.l    d0,d7
  6981.     beq    DOSerr
  6982.     bsr    fibexam2
  6983.     move.l    d7,d1
  6984.     jsr    _LVOUnLock(a6)
  6985.     lea    -14(sp),sp
  6986.     lea    (sp),a0
  6987.     lea    fib_Date(a5),a1
  6988.     bsr    convert_time
  6989.     lea    parm3(a5),a0
  6990.     lea    (sp),a1
  6991.     bsr    settime
  6992.     move.w    12(sp),d1
  6993.     lea    14(sp),sp
  6994.     tst.l    d0
  6995.     beq    .B
  6996.     rts
  6997.  
  6998. .B    lea    (a3),a0
  6999.     move.l    d5,(a0)+    ;days
  7000.     divu    #60,d6
  7001.     move.w    d6,d0
  7002.     ext.l    d0
  7003.     move.l    d0,(a0)+    ;mins
  7004.     swap    d6
  7005.     mulu    #50,d6
  7006.     add.l    d1,d6
  7007.     move.l    d6,(a0)        ;ticks
  7008. nospda    move.l    a2,d1    ;filename
  7009.     jsr    _LVODeviceProc(a6)
  7010.     tst.l    d0
  7011.     beq    DOSerr
  7012.     move.l    d0,packettask(a5)
  7013.     move.l    a2,a0
  7014.     lea    temp2buf(a5),a1
  7015.     move.l    a1,a3
  7016.     bsr    split_wild    No wildcard ! Only separates filename !
  7017.     move.l    a2,d1
  7018.     moveq    #ACCESS_READ,d2
  7019.     jsr    _LVOLock(a6)
  7020.     move.l    d0,d7
  7021.     beq    DOSerr
  7022.     move.l    d0,myArg2(a5)    ;BPTR lock
  7023.     move.l    a3,a0
  7024.     lea    tempbuf(a5),a1
  7025.     moveq    #-1,d0
  7026.     bsr    cpBSTR
  7027.     move.l    d0,myArg3(a5)    ;BSTR filename
  7028.     moveq    #ACTION_SET_DATE,d0
  7029.     move.l    d0,packettype(A5)
  7030.     bsr    sendpacket
  7031.     move.l    d7,d1
  7032.     jsr    _LVOUnLock(a6)
  7033.     bsr    PKTerr
  7034.     moveq    #RETURN_OK,d0
  7035.     rts
  7036.  
  7037. *************************
  7038. *    DISKCHANGE    *
  7039. *************************
  7040. diskchangez
  7041.     tst.l    parm2(a5)
  7042.     beq    too_less_args
  7043.     move.l    parm2(a5),d1    PARM2=DF0: etc
  7044.     jsr    _LVODeviceProc(a6)
  7045.     tst.l    d0
  7046.     beq    DOSerr
  7047.     move.l    d0,packettask(a5)
  7048.     bsr    changedisk
  7049.     moveq    #RETURN_OK,d0
  7050.     rts
  7051.  
  7052. ** USES task in packettask
  7053. changedisk
  7054.     bsr    clearArgs
  7055.     moveq    #ACTION_INHIBIT,d0
  7056.     move.l    d0,packettype(a5)
  7057.     moveq    #-1,d0    ;1?
  7058.     move.l    d0,myArg1(a5)
  7059.     bsr    sendpacket
  7060.     bsr    PKTerr
  7061.     clr.l    myArg1(a5)
  7062.     bsr    sendpacket
  7063.     bsr    PKTerr
  7064.     rts
  7065.  
  7066. *************************
  7067. *    LOCK        *
  7068. *************************
  7069. lockz    move.l    parm3(a5),a0
  7070.     moveq    #-1,d7
  7071.     bsr    CheckOnOff
  7072.     bne.s    .B
  7073.     moveq    #0,d7
  7074. .B    move.l    parm2(a5),d1    PARM2=DF0: etc
  7075.     beq    too_less_args
  7076.     jsr    _LVODeviceProc(a6)
  7077.     tst.l    d0
  7078.     beq    DOSerr
  7079.     move.l    d0,packettask(a5)
  7080.     bsr    clearArgs
  7081.     move.l    #ACTION_WRITE_PROTECT,d0
  7082.     move.l    d0,packettype(a5)
  7083.     move.l    d7,myArg1(a5)
  7084.     bsr    sendpacket
  7085.     bsr    PKTerr
  7086.     moveq    #RETURN_OK,d0
  7087.     rts
  7088.  
  7089. *********************************
  7090. *    UNSET VARIABLE        *
  7091. *********************************
  7092. unsetz    lea    parm2(a5),a3
  7093. .A    tst.l    (a3)
  7094.     beq    no_more_unsets
  7095.     move.l    (a3)+,a0
  7096.     bsr    check_if_set_already_there
  7097.     tst.l    d0
  7098.     beq    unset_failure
  7099.     move.l    d0,a1
  7100.     move.l    (a1),d2    GRAB NEXT SET POINTER
  7101.     move.l    set_size(a1),d0
  7102.     move.l    d1,a0    D1=prior set
  7103.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  7104.     bsr    givemem
  7105.     bra    .A
  7106. no_more_unsets
  7107.     moveq    #RETURN_OK,d0
  7108.     rts
  7109. unset_failure
  7110.     lea    temp2buf(a5),a1
  7111.     bsr    pr_string
  7112.     lea    bad_unset_tx(pc),a1
  7113.     bsr    pr_string
  7114.     moveq    #RETURN_ERROR,d0
  7115.     rts
  7116.  
  7117. *********************************
  7118. *    SET VARIABLE KEY    *
  7119. *********************************
  7120. set_link    equ    0
  7121. set_size    equ    4
  7122. set_name    equ    8
  7123. set_defn    equ    24
  7124.  
  7125. set_funcz
  7126.     move.l    parm2(a5),d0        SEE IF ANY PARAMETERS TYPED
  7127.     beq.s    show_current_sets
  7128.     tst.l    parm3(a5)
  7129.     beq.s    show_current_sets    
  7130.     move.l    d0,a0        A0=parm2
  7131.     bsr    check_if_set_already_there
  7132.     tst.l    d0
  7133.     beq    create_new_set
  7134.     movem.l    a0-a1,-(sp)    * update old set
  7135.     move.l    d0,a1        first delete old one
  7136.     move.l    (a1),d2    GRAB NEXT SET POINTER
  7137.     move.l    set_size(a1),d0
  7138.     move.l    d1,a0    D1=prior set
  7139.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  7140.     bsr    givemem
  7141.     movem.l    (sp)+,a0-a1     and replace with new set
  7142.     bra    create_new_set
  7143.  
  7144. show_current_sets
  7145.     bsr    rawh_off
  7146.     move.l    first_set_defn(a5),d0
  7147.     beq    no_sets_to_show
  7148. show_next_set
  7149.     move.l    d0,a3
  7150.     lea    set_name(a3),a1
  7151.     bsr    pr_string
  7152.     bsr    pr_tab
  7153.     lea    set_defn(a3),a1
  7154.     bsr    pr_stringlf
  7155.     move.l    (a3),d0        CHECK NEXT SET ADDRESS
  7156.     bne    show_next_set
  7157. no_sets_to_show
  7158.     moveq    #RETURN_OK,d0
  7159.     rts
  7160.  
  7161. create_new_set        ;a0=name a1=def
  7162.     lea    tempbuf(a5),a3        GET BIG BLOCK
  7163.     lea    set_name(a3),a1
  7164.     bsr    cp_string        COPY SET NAME TO SPACE
  7165.     bsr    ConvertSemi
  7166.     lea    CLIbuf(a5),a0    use CLIbuf, end in a1
  7167. .D    move.b    (a0)+,d0
  7168.     beq.s    .C
  7169.     cmp.b    #" ",d0        search for space
  7170.     bne.s    .D
  7171. .E    move.b    (a0)+,d0
  7172.     cmp.b    #" ",d0        check multiple spaces
  7173.     beq.s    .E
  7174.     cmp.b    #$22,-1(a0)    check for "
  7175.     bne.s    .G
  7176.     cmp.b    #$22,-2(a1)    surrounded by " " ?
  7177.     bne.s    .G
  7178.     clr.b    -2(a1)
  7179.     addq.l    #1,a0
  7180. .G    lea    set_defn(a3),a1    store definition
  7181. .C    subq.l    #1,a0
  7182. .F    move.b    (a0)+,(a1)+
  7183.     bne.s    .F
  7184.     move.l    a1,d4        D4=after end
  7185.     sub.l    a3,a1        WORK OUT HOW BIG IS ACTUALLY
  7186.     move.l    a1,d0
  7187.     moveq    #1,d1
  7188.     bsr    iwantmem    allocate block big enough for everything
  7189.     beq.s    .A
  7190.     move.l    d0,a2
  7191.     move.l    a1,set_size(a2)
  7192.     move.l    first_set_defn(a5),d1
  7193.     move.l    d1,(a2)            new pts to old
  7194.     move.l    a2,first_set_defn(a5)
  7195.     lea    set_name(a2),a1    new block
  7196.     lea    set_name(a3),a0    temp block
  7197. .B    move.b    (a0)+,(a1)+
  7198.     cmp.l    a0,d4
  7199.     bne.s    .B
  7200. .A    moveq    #RETURN_OK,d0
  7201.     rts
  7202.  
  7203. check_if_set_already_there
  7204. * A0= set name
  7205.     movem.l    a0-a1,-(sp)
  7206.     lea    temp2buf(a5),a1
  7207.     bsr    cp_string
  7208.     bsr    search_sets
  7209.     movem.l    (sp)+,a0-a1
  7210.     rts
  7211.  
  7212. deallocate_sets
  7213.     move.l    first_set_defn(a5),d3
  7214.     beq    no_sets_to_lose
  7215. lose_next_set
  7216.     move.l    d3,a1
  7217.     move.l    (a1),-(sp)
  7218.     move.l    set_size(a1),d0
  7219.     bsr    givemem
  7220.     move.l    (sp)+,d3
  7221.     bne    lose_next_set
  7222. no_sets_to_lose
  7223.     rts
  7224.  
  7225. ConvertSemi    ;convert \; into ; from/to CLIbuf
  7226.     lea    CLIbuf(a5),a0
  7227.     move.l    a0,a1
  7228.     moveq    #0,d1
  7229. .A    move.b    (a0)+,d0
  7230.     cmp.b    #$5c,d1    ;\
  7231.     bne.s    .D
  7232.     cmp.b    #";",d0
  7233.     bne.s    .D
  7234.     subq.l    #1,a1
  7235. .D    move.b    d0,(a1)+
  7236.     move.b    d0,d1
  7237.     bne.s    .A
  7238.     rts
  7239.  
  7240. *************************
  7241. *    RESIDENT    *    V2.0:uses the GLOBAL resident-list
  7242. *************************    (many things changed)
  7243. residentz    move.l    parm2(a5),d0    SEE IF ANY PARAMETERS TYPED
  7244.     beq    show_current_residents
  7245.     lea    parm2(a5),a3
  7246.     move.l    (a3),a0
  7247.     bsr    return_dash_option
  7248.     cmp.b    #'C',d0
  7249.     beq    kill_resi
  7250. next_resi    move.l    (a3)+,d0
  7251.     bne.s    .B
  7252.     moveq    #RETURN_OK,d0
  7253.     rts
  7254. .B    move.l    d0,a4        A4=parmName
  7255.     move.l    a3,-(sp)
  7256.     bsr    spaths2        SEARCH PATHS FOR THE COMMAND
  7257.     move.l    (sp)+,a3
  7258.     move.l    d0,-(sp)
  7259.     move.l    closecdir(a5),d1
  7260.     beq.s    .G
  7261.     jsr    _LVOUnLock(a6)
  7262.     clr.l    closecdir(a5)
  7263. .G    move.l    (sp)+,d0
  7264.     beq    resi_not_found
  7265.     move.l    d0,-(sp)    push seglist
  7266.     move.l    a4,a0
  7267.     move.l    a4,a1
  7268.     bsr    rempath        SRC = DEST is OK
  7269.     bsr    search_res2    find if same name is on resi list
  7270.     move.l    (sp)+,d3
  7271.     move.l    d0,d1
  7272.     bne.s    .A
  7273.     bsr    create_resi
  7274.     bra.s    next_resi
  7275. .A    moveq    #1,d0
  7276.     cmp.l    resi_usecount(a0),d0
  7277.     bne.s    resi_inuse
  7278.     move.l    d0,resi_usecount(a0)
  7279.     move.l    d3,resi_seglist(a0)    new seglist
  7280.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  7281.     bra.s    next_resi
  7282.  
  7283. kill_resi    tst.l    (a3)+
  7284. .B    move.l    (a3)+,d0
  7285.     bne.s    .A
  7286.     moveq    #RETURN_OK,d0
  7287.     rts
  7288. .A    move.l    d0,a4
  7289.     move.l    a4,a0
  7290.     move.l    a4,a1
  7291.     bsr    rempath        SRC = DEST is OK
  7292.     bsr    search_res2    find if same name is on resi list
  7293.     move.l    d0,d1        gives d0,a0,d2
  7294.     beq.s    resi_not_found
  7295.     moveq    #1,d0
  7296.     cmp.l    resi_usecount(a0),d0
  7297.     bne.s    resi_inuse
  7298.     move.l    a0,a2
  7299.     move.l    d2,a0
  7300.     move.l    resi_link(a2),resi_link(a0)
  7301.     clr.l    resi_link(a2)
  7302.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  7303.     move.l    a2,d1
  7304.     lsr.l    #2,d1
  7305.     jsr    _LVOUnLoadSeg(a6)
  7306.     bra.s    .B
  7307.  
  7308. resi_not_found
  7309.     move.l    #205,d0
  7310.     bra.s    resi_error
  7311. resi_no_mem
  7312.     moveq    #103,d0
  7313.     bra.s    resi_error
  7314. resi_inuse
  7315.     move.l    #202,d0
  7316. resi_error
  7317.     move.l    dosbase(a5),a6
  7318.     bra    pr_galactic
  7319.  
  7320. create_resi        ;D3:SegList, A4:Name
  7321.     moveq    #resi_length,d0
  7322.     move.l    a4,a0
  7323. .A    addq.l    #1,d0    one more for lenght-byte
  7324.     tst.b    (a0)+
  7325.     bne.s    .A
  7326.     addq.l    #4,d0    4 more for segment-length
  7327.     addq.l    #7,d0    (7 more for and'ing needed by UnLoadSeg)
  7328.     moveq    #-4,d1
  7329.     and.l    d1,d0
  7330.     move.l    d0,d2
  7331.     moveq    #1,d1
  7332.     bsr    iwantmem
  7333.     beq.s    resi_no_mem
  7334.     addq.l    #4,d0
  7335.     move.l    d0,a2        D0=addr of resi_list_node
  7336.     move.l    d2,-4(a2)    save segment-length
  7337.     bsr    do_forbid
  7338.     bsr    resi_hand
  7339.     move.l    d0,resi_link(a2)
  7340.     move.l    a2,d0
  7341.     lsr.l    #2,d0
  7342.     move.l    d0,(a0)
  7343.     moveq    #1,d0
  7344.     move.l    d0,resi_usecount(a2)
  7345.     move.l    d3,resi_seglist(a2)
  7346.     lea    resi_name(a2),a1
  7347.     move.l    a4,a0
  7348.     moveq    #-1,d0
  7349.     bsr    cpBSTR
  7350.     bsr    do_permit
  7351.     moveq    #0,d0
  7352.     rts
  7353.  
  7354. resi_hand    move.l    dl_Root(a6),a0
  7355.     move.l    rn_Info(a0),a0
  7356.     add.l    a0,a0
  7357.     add.l    a0,a0
  7358.     lea    di_NetHand(a0),a0    NetHand in A0
  7359.     move.l    (a0),d0        Start of Resi-List in D0
  7360.     rts
  7361.  
  7362. show_current_residents
  7363.     lea    residetx(pc),a1
  7364.     bsr    pr_stringlf
  7365.     bsr    rawh_off
  7366.     bsr    resi_hand
  7367.     beq    no_resis_to_show
  7368. .A    lsl.l    #2,d0
  7369.     move.l    d0,a3
  7370.     move.l    resi_usecount(a3),d0
  7371.     subq.l    #1,d0
  7372.     bsr    print10
  7373.     bsr    pr_space
  7374.     move.l    a3,d0
  7375.     bsr    printADR
  7376.     bsr    pr_space
  7377.     lea    resi_name(a3),a1
  7378.     moveq    #0,d3
  7379.     move.b    (a1)+,d3
  7380.     move.l    a1,d2
  7381.     move.l    outhandle(a5),d1
  7382.     beq.s    .B
  7383.     jsr    _LVOWrite(a6)
  7384.     bsr    pr_lf
  7385. .B    bsr    check_c
  7386.     bne.s    no_resis_to_show
  7387.     move.l    resi_link(a3),d0
  7388.     bne    .A
  7389. no_resis_to_show
  7390.     moveq    #RETURN_OK,d0
  7391.     rts
  7392.  
  7393. ******    Copy String from A0 to BSTR A1
  7394. cpBSTR    movem.l    d1-d2/a0-a2,-(sp)    max. Length-2 in D0
  7395.     lea    1(a1),a2
  7396.     moveq    #0,d2
  7397.     bra.s    .B
  7398. .A    move.b    d1,(a2)+
  7399.     addq.l    #1,d2
  7400. .B    move.b    (a0)+,d1
  7401.     dbeq    d0,.A
  7402.     clr.b    (a2)    ;NULL-end it
  7403.     move.b    d2,(a1)
  7404.     move.l    a1,d0
  7405.     lsr.l    #2,d0
  7406.     movem.l    (sp)+,d1-d2/a0-a2    D0 is BPTR to the BSTR
  7407.     rts
  7408.  
  7409.  
  7410. *********************************
  7411. *    RPN CALCULATOR        *
  7412. *********************************
  7413. evalz    lea    parm2(a5),a4
  7414.     move.l    sp,d5        remember the stack ptr
  7415. rpn_loop1    move.l    (a4)+,d1
  7416.     beq    show_rpn_result
  7417.     lea    endofparms(a5),a1
  7418.     cmp.l    a1,a4
  7419.     bhi    show_rpn_result
  7420.     move.l    d1,a1
  7421.     lea    8(sp),a0
  7422.     cmp.l    a0,d5
  7423.     blo    not_poke32
  7424.  
  7425.     cmp.b    #'+',(a1)        
  7426.     bne.s    not_add        
  7427.     move.l    (sp)+,d0        DO ADD
  7428.     add.l    d0,(sp)
  7429.     bra    rpn_loop1
  7430. not_add    cmp.b    #'-',(a1)
  7431.     bne.s    not_sub
  7432.     move.l    (sp)+,d0
  7433.     sub.l    d0,(sp)
  7434.     bra    rpn_loop1
  7435.     
  7436. not_sub    cmp.b    #'*',(a1)
  7437.     bne.s    not_mult
  7438.     move.l    (sp)+,d0    last    DO MULT
  7439.     move.l    (sp)+,d1    2nd last
  7440.     bsr    mult_32x32
  7441.     move.l    d0,-(sp)
  7442.     bra    rpn_loop1
  7443. not_mult    cmp.b    #'/',(a1)
  7444.     bne.s    not_div
  7445.     move.l    (sp)+,d1    last    DO DIVIDE
  7446.     move.l    (sp)+,d0    2nd last
  7447.     tst.l    d1
  7448.     beq    rpn_error        NO DIVIDE BY ZERO
  7449.     bsr    div_32
  7450.     move.l    d0,-(sp)
  7451.     bra    rpn_loop1
  7452. not_div    cmp.b    #'&',(a1)
  7453.     bne.s    not_and
  7454.     move.l    (sp)+,d0
  7455.     and.l    d0,(sp)
  7456.     bra    rpn_loop1
  7457. not_and    cmp.b    #"|",(a1)
  7458.     bne.s    not_or
  7459.     move.l    (sp)+,d0
  7460.     or.l    d0,(sp)
  7461.     bra    rpn_loop1
  7462. not_or    cmp.b    #'!',(a1)
  7463.     bne.s    not_poke32
  7464.     move.l    (sp)+,d0    GET ADDR        DO POKE 32
  7465.     move.l    (sp)+,d1    GET VALUE
  7466.     and.b    #$fe,d0
  7467.     move.l    d0,a0
  7468.     move.l    d1,(a0)
  7469.     bra    rpn_loop1
  7470. not_poke32
  7471.     cmp.b    #'@',(a1)
  7472.     bne.s    not_peek32
  7473.     move.l    (sp)+,d0    ADDR    DO PEEK 32
  7474.     cmp.l    sp,d5
  7475.     blo    rpn_error
  7476.     and.b    #$fe,d0
  7477.     move.l    d0,a0
  7478.     move.l    (a0),-(sp)
  7479.     bra    rpn_loop1
  7480.  
  7481. not_peek32
  7482.     bsr    convert_ASCII_to_num
  7483.     beq    rpn_error
  7484.     move.l    d0,-(sp)
  7485.     bra    rpn_loop1
  7486. rpn_error    move.l    d5,sp
  7487.     rts
  7488.  
  7489. show_rpn_result
  7490.     move.l    (sp),-(sp)
  7491.     moveq    #RETURN_ERROR,d7    error on equal
  7492.     tst.l    (sp)
  7493.     beq.s    .B
  7494.     bpl.s    .C
  7495.     moveq    #RETURN_WARN,d7        warn on minus
  7496.     bra.s    .B
  7497. .C    moveq    #RETURN_OK,d7        ok on plus
  7498. .B    lea    (sp),a1
  7499.     move.l    sp,a1
  7500.     lea    rpn_result_tx(pc),a0    print hex & dec
  7501.     move.l    outhandle(a5),d0
  7502.     cmp.l    stdout(a5),d0    output redirected ?
  7503.     beq.s    .A
  7504.     moveq    #RETURN_OK,d7
  7505.     lea    rpn_res2(pc),a0    print only number
  7506. .A    bsr    new_print
  7507.     move.l    d5,sp
  7508.     move.l    d7,d0
  7509.     rts
  7510.  
  7511. div_32    movem.l    d2-d4,-(sp)    ;d0=d0/d1
  7512.     moveq    #0,d2
  7513.     moveq    #31,d4
  7514. _divu1    roxl.l    #1,d0    ; divident
  7515.     roxl.l    #1,d2    ; work accum
  7516.     cmp.l    d1,d2    ; cmp with divisor
  7517.     blo.s    _divu2
  7518.     sub.l    d1,d2
  7519.     dc.l    $003c0010    ;ori.b    #16,CCR    ;setx
  7520. _divu2    roxl.l    #1,d3    ; result
  7521.     dbf    d4,_divu1
  7522.     move.l    d3,d0
  7523.     move.l    d2,d1
  7524.     movem.l    (sp)+,d2-d4    ;result:d0 rest:d1
  7525.     rts
  7526.  
  7527.  
  7528. mult_32x32
  7529. * D1 = 32 bit, D0 = 32 bit (result)
  7530.     movem.l    d1-d3,-(sp)
  7531.     move.l    d0,d2
  7532.     move.l    d0,d3
  7533.     mulu    d1,d0    save intermediate result
  7534.     swap    d3
  7535.     mulu    d1,d3
  7536.     swap    d3
  7537.     clr.w    d3
  7538.     add.l    d3,d0
  7539.     swap    d1
  7540.     mulu    d1,d2
  7541.     swap    d2
  7542.     clr.w    d2
  7543.     add.l    d2,d0
  7544.     movem.l    (sp)+,d1-d3
  7545.     rts
  7546.  
  7547. * Convert null ending ASCII number(A1) to 32bit number in D0
  7548. * Return D1=0 if bad number (a1:current pos)
  7549. convert_ASCII_to_num    
  7550.     movem.l    d2/d3/a0,-(sp)
  7551.     moveq    #0,d3    SET POSITIVE
  7552.     moveq    #0,d1    RESET BASE
  7553. .A    cmp.b    #'|',(a1)
  7554.     bne.s    convnor
  7555.     lea    1(a1),a0
  7556.     bsr    readfile
  7557.     cmp.w    #NEWPRINTSIZE-2,d1
  7558.     bhs    conversion_finished
  7559.     move.l    d0,a0
  7560.     lea    NewPrintBuffer(a5),a1
  7561.     move.l    d1,d2
  7562.     subq.w    #1,d2
  7563. .B    move.b    (a0)+,(a1)+
  7564.     dbra    d2,.B
  7565.     clr.b    (a1)
  7566.     move.l    d0,a1
  7567.     move.l    d1,d0
  7568.     bsr    givemem
  7569.     lea    NewPrintBuffer(a5),a1
  7570. ;    bset    #0,d3
  7571.     bra.s    .A
  7572. convnor    moveq    #0,d0    RESET RESULT
  7573.     moveq    #0,d1    RESET BASE
  7574.     tst.b    (a1)
  7575.     beq    conversion_finished
  7576.     moveq    #LF,d1    SET THE BASE
  7577.     cmp.b    #'-',(a1)    negative sign
  7578.     bne.s    .A
  7579.     bset    #3,d3
  7580. .D    addq.l    #1,a1
  7581. .A    cmp.b    #'+',(a1)    positive sign
  7582.     beq.s    .D
  7583.     cmp.b    #'&',(a1)    for APTR (hex!) -> BPTR
  7584.     bne.s    .B
  7585.     addq.l    #1,a1
  7586.     bset    #1,d3
  7587.     moveq    #16,d1    SET RADIX16
  7588.     bra    same_base
  7589. .B    cmp.b    #'§',(a1)    for BPTR (hex!) -> APTR
  7590.     bne.s    .C
  7591.     addq.l    #1,a1
  7592.     bset    #2,d3
  7593.     moveq    #16,d1    SET RADIX16
  7594.     bra    same_base
  7595. .C    cmp.b    #'$',(a1)
  7596.     bne.s    other_base
  7597.     move.b    (a1)+,d2    DUMMY BUMP
  7598.     moveq    #16,d1    SET RADIX16
  7599.     bra    same_base
  7600.  
  7601. other_base
  7602.     cmp.b    #'%',(a1)
  7603.     bne.s    same_base
  7604.     move.b    (a1)+,d2
  7605.     moveq    #2,d1    SET RADIX2
  7606. same_base    moveq    #0,d2
  7607.     move.b    (a1)+,d2
  7608.     beq    conversion_finished
  7609.     bsr    convert_D2_to_num
  7610.     tst.l    d1
  7611.     beq.s    conversion_finished
  7612.     bsr    mult_32x32
  7613.     add.l    d2,d0
  7614.     bra    same_base
  7615. conversion_finished
  7616.     btst    #3,d3
  7617.     beq.s    .A
  7618.     neg.l    d0
  7619. .A    btst    #1,d3
  7620.     beq.s    .B
  7621.     lsr.l    #2,d0
  7622. .B    btst    #2,d3
  7623.     beq.s    .C
  7624.     lsl.l    #2,d0
  7625. .C    movem.l    (sp)+,d2/d3/a0
  7626.     tst.b    d1
  7627.     rts
  7628.     
  7629. convert_D2_to_num
  7630.     cmp.b    #'0',d2
  7631.     blo.s    bad_number
  7632.     cmp.b    #'9',d2
  7633.     bhi.s    check_hex
  7634.     sub.b    #'0',d2
  7635.     rts
  7636. check_hex    cmp.b    #16,d1
  7637.     bne.s    bad_number
  7638.     cmp.b    #'f',d2
  7639.     bhi.s    bad_number
  7640.     cmp.b    #'A',d2
  7641.     blo.s    bad_number
  7642.     cmp.b    #'F',d2
  7643.     bhi.s    check_upper_hex
  7644.     sub.b    #55,d2
  7645.     rts
  7646. check_upper_hex
  7647.     cmp.b    #'a',d2
  7648.     blo.s    bad_number
  7649.     sub.b    #87,d2
  7650.     rts
  7651. bad_number
  7652.     moveq    #0,d1    FLAG ERROR thru silly base
  7653.     rts
  7654.  
  7655. *********************************
  7656. *    MEMORY EXAMINE        *
  7657. *********************************
  7658. memexamz    clr.l    mem_offset_addr(a5)
  7659.     moveq    #0,d7
  7660.     tst.l    parm2(a5)        CHECK IF NO ADDRESS.
  7661.     bne.s    .E
  7662.     moveq    #8,d7
  7663.     bra    show_mempage
  7664. .E    bsr    fixpam32
  7665.     tst.b    (a1)
  7666.     beq.s    .A
  7667.     move.l    a0,-(sp)
  7668.     bsr    convert_ASCII_to_num    convert 2nd num
  7669.     move.l    (sp)+,a0
  7670.     tst.b    d1
  7671.     beq    bad_number_error
  7672.     move.l    d0,d7            D7=2nd num
  7673. .A    move.l    a0,a1
  7674.     bsr    convert_ASCII_to_num    convert 1st num
  7675.     beq    bad_number_error
  7676. .C    tst.l    d7
  7677.     bne.s    .D
  7678.     moveq    #8,d7
  7679.     bra.s    memex2
  7680. .D    sub.l    d0,d7
  7681.     lsr.l    #4,d7
  7682.     addq.l    #1,d7
  7683.  
  7684. memex2    move.l    d0,mem_addr(a5)
  7685. show_mempage
  7686.     and.b    #$fe,mem_addr+3(a5)    MAKE SURE EVEN ADDRESS
  7687. shmem2    bsr    check_c
  7688.     bne    .A
  7689.     bsr    show_16_locs
  7690.     subq.l    #1,d7        D7=count
  7691.     bne.s    shmem2
  7692. .A    moveq    #RETURN_OK,d0
  7693.     rts
  7694.     
  7695. show_16_locs
  7696.     move.l    mem_addr(a5),a1
  7697.     lea    CLIbuf(a5),a3
  7698.     move.l    a3,a0
  7699.     moveq    #15,d0
  7700. sh_16_1    move.b    (a1)+,d1
  7701.     move.b    #'.',(a0)+
  7702.     move.b    d1,d2
  7703.     bclr    #7,d2
  7704.     cmp.b    #' ',d2
  7705.     blo.s    sh_16_2
  7706.     move.b    d1,-1(a0)
  7707. sh_16_2    dbra    d0,sh_16_1
  7708.     clr.b    (a0)
  7709.     move.l    a3,-(sp)        PUSH STRING ADDR
  7710.     move.l    -(a1),-(sp)    PUSH LAST BYTES
  7711.     move.l    -(a1),-(sp)
  7712.     move.l    -(a1),-(sp)
  7713.     move.l    -(a1),-(sp)    PUSH FIRST BYTES
  7714.     move.l    mem_addr(a5),d0
  7715.     sub.l    mem_offset_addr(a5),d0
  7716.     move.l    d0,-(sp)
  7717.     lea    mem_line(pc),a0
  7718.     lea    (sp),a1
  7719.     bsr    new_print
  7720.     movem.l    (sp)+,d0-d5    DUMMY
  7721.     add.l    #16,mem_addr(a5)
  7722.     rts
  7723.  
  7724. * ENTRY A0=FORMATSTRING A1=DATASTREAM.
  7725. new_print    ;v2.0 small data
  7726.     movem.l    d0-d3/a0-a3,-(sp)
  7727.     lea    NewPrintBuffer(a5),a3    ;V2.0 not on stack
  7728.     lea    KPutChar(pc),a2
  7729.     move.l    4.w,a6
  7730.     jsr    _LVORawDoFmt(a6)
  7731.     move.l    dosbase(a5),a6
  7732.     move.l    outhandle(a5),d1
  7733.     beq.s    .B
  7734.     lea    NewPrintBuffer(a5),a0
  7735.     move.l    a0,d2
  7736.     moveq    #-1,d3
  7737. .A    addq.l    #1,d3
  7738.     tst.b    (a0)+
  7739.     bne.s    .A
  7740.     jsr    _LVOWrite(a6)
  7741. .B    movem.l    (sp)+,d0-d3/a0-a3
  7742.     rts
  7743.  
  7744. KPutChar move.b    d0,(a3)+
  7745.     rts
  7746.  
  7747. GetDiskInfo    ;device-task must be in packettask(a5), gets info to a5
  7748.     bsr    clearArgs
  7749.     moveq    #ACTION_DISK_INFO,d0
  7750.     move.l    d0,packettype(a5)
  7751.     move.l    a5,d0
  7752.     lsr.l    #2,d0
  7753.     move.l    d0,myArg1(a5)    use FIB as INFO (bptr)
  7754.     bsr    sendpacket
  7755.     rts
  7756.     sub.l    a0,a0
  7757.     tst.l    sp_res1(a5)
  7758.     beq.s    .A
  7759.     move.l    id_VolumeNode(a5),a0    it is in here !
  7760. .A    rts
  7761.  
  7762. CountLocks    ;Exit: d0=number of all locks in system
  7763.     movem.l    d1/d2/a2,-(sp)
  7764.     clr.l    temp3(a5)
  7765.     bsr    do_forbid
  7766.     bsr    get_first_devinfo
  7767. .D    moveq    #dlt_device,d1
  7768.     bsr    find_next_assign    walk through dos-list
  7769.     tst.l    d0
  7770.     bne.s    .C
  7771.     move.l    8(a0),packettask(a5)    task
  7772.     beq.s    .D        was non-disk-device
  7773.     bsr    GetDiskInfo
  7774.     move.l    id_InUse(a5),d0    lock
  7775.     beq.s    .D
  7776. .A    addq.l    #1,temp3(a5)    count locks
  7777.     lsl.l    #2,d0
  7778.     move.l    d0,a0
  7779.     move.l    (a0),d0
  7780.     bne.s    .A
  7781.     bra.s    .D
  7782. .C    bsr    do_permit
  7783.     move.l    temp3(a5),d0
  7784.     movem.l    (sp)+,d1/d2/a2
  7785.     rts
  7786.  
  7787. ** SAVE STATS store current time in date mark, and current memory use in mem mark
  7788. save_time
  7789.     movem.l    d0-d1/a0,-(sp)
  7790.     lea    date_mark(a5),a0
  7791.     bsr    get_time
  7792.     movem.l    (sp)+,d0-d1/a0
  7793.     rts
  7794. save_mem    movem.l    d0-d1/a0-a1,-(sp)
  7795.     clr.l    temp2(a5)
  7796.     btst    #FLcheck,Flags+3(a5)
  7797.     beq.s    .C
  7798.     move.l    4.w,a0
  7799.     tst.w    296(a0)        CPU better than 68000 ?
  7800.     bne.s    .A
  7801.     move.l    #1024,d0    no, store lower memory
  7802.     moveq    #1,d1
  7803.     bsr    iwantmem
  7804.     move.l    d0,temp2(a5)
  7805.     beq.s    .A
  7806.     move.l    d0,a1
  7807.     sub.l    a0,a0        adress 0 to 1023
  7808.     move.l    #1024/4-1,d0
  7809. .B    move.l    (a0)+,(a1)+
  7810.     dbra    d0,.B
  7811. .A    bsr    CountLocks
  7812.     lea    mem_mark(a5),a0
  7813.     bsr    memory_info    remember memory usage
  7814. .C    movem.l    (sp)+,d0-d1/a0-a1
  7815.     rts
  7816.  
  7817. ** DISPLAY TIME ELAPSED SINCE LAST CALL TO SAVE TIME AND
  7818. **  ALSO CHANGE IN MEMORY AVAILABLE. EXPECTS RETURN CODE TO BE ABOVE RETURN
  7819. **  ADDRESS ON STACK ie 4(sp)
  7820. show_status
  7821.     lea    -34(sp),sp
  7822.     lea    (sp),a0        A0=time area
  7823.     move.l    Result2(a5),(a0)+    -4(a0) ioerr-result
  7824.     bsr    get_time    
  7825.     lea    date_mark(a5),a1
  7826.     move.l    ds_Tick(a0),d0
  7827.     sub.l    ds_Tick(a1),d0
  7828.     bpl.s    no_tick_carry
  7829.     add.l    #3000,d0
  7830.     subq.l    #1,ds_Minute(a0)
  7831. no_tick_carry
  7832.     move.l    d0,ds_Tick(a1)    store in datemark
  7833.     move.l    ds_Minute(a0),d0
  7834.     sub.l    ds_Minute(a1),d0
  7835.     move.l    d0,ds_Minute(a1)
  7836.     bsr    convert_time    A0=4+3 words of time
  7837. do_mem_deltas
  7838.     lea    14(a0),a0
  7839.     bsr    memory_info
  7840.     lea    mem_mark(a5),a1
  7841.     move.l    (a1),d0
  7842.     sub.l    d0,(a0)    subtract old from new    ;chip
  7843.     move.l    4(a1),d0
  7844.     sub.l    d0,4(a0)            ;fast
  7845.     move.l    8(a1),d0
  7846.     sub.l    d0,8(a0)            ;total
  7847.     lea    -12(a0),a1
  7848.     move.l    -18(a0),(a1)
  7849.     lea    stat_text(pc),a0
  7850.     bsr    new_print
  7851.     lea    34(sp),sp
  7852.     move.l    temp3(a5),d1    check for forgotten locks
  7853.     bsr    CountLocks
  7854.     cmp.l    d1,d0
  7855.     beq.s    .D
  7856.     exg.l    d0,d1
  7857.     movem.l    d0/d1,-(sp)
  7858.     move.l    sp,a1
  7859.     lea    lockleft(pc),a0
  7860.     bsr    new_print
  7861.     addq.l    #8,sp
  7862. .D    move.l    temp2(a5),d0
  7863.     beq.s    .A
  7864.     move.l    d0,a1        show changes of low memory
  7865.     sub.l    a0,a0
  7866.     move.l    #1024/4-1,d0
  7867. .B    move.l    (a0)+,d1
  7868.     cmp.l    (a1)+,d1
  7869.     beq.s    .C
  7870.     movem.l    a0-a1,-(sp)
  7871.     move.l    -4(a0),-(sp)
  7872.     move.l    -4(a1),-(sp)
  7873.     move.l    a0,-(sp)
  7874.     subq.l    #4,(sp)
  7875.     move.l    sp,a1
  7876.     lea    lowmemtx(pc),a0    print the changes
  7877.     bsr    new_print
  7878.     lea    12(sp),sp
  7879.     movem.l    (sp)+,a0-a1
  7880. .C    dbra    d0,.B
  7881.     move.l    temp2(a5),a1
  7882.     move.l    #1024,d0
  7883.     bsr    givemem
  7884. .A    rts
  7885.  
  7886. *************************    
  7887. *    DATE/TIME    *
  7888. *************************
  7889. datez    lea    date_mark(a5),a2
  7890.     move.l    a2,a0
  7891.     bsr    get_time
  7892.     move.l    a2,a1
  7893.     lea    -14(sp),sp
  7894.     lea    (sp),a0
  7895.     bsr    convert_time
  7896.     tst.l    parm2(a5)
  7897.     beq.s    .A
  7898.     lea    parm2(a5),a0
  7899.     lea    (sp),a1
  7900.     bsr.s    settime
  7901.     lea    14(sp),sp
  7902.     bne.s    .B
  7903.     bsr    tset
  7904.     clr.l    parm2(a5)
  7905.     bra.s    datez    ;now print date/time
  7906. .A    lea    (sp),a1
  7907.     lea    time_text(pc),a0
  7908.     bsr    new_print
  7909.     lea    14(sp),sp
  7910.     moveq    #RETURN_OK,d0
  7911. .B    rts
  7912.  
  7913. settime    movem.l    d1-d4/a0-a4,-(sp)    V2.0
  7914.     move.l    a0,a4        ;a0=parameters
  7915.     move.l    a1,temp1(a5)    ;a1=date/time
  7916. settim    move.l    (a4)+,a0
  7917.     lea    temp2buf(a5),a2
  7918.     moveq    #2,d3
  7919. aa1    move.l    a0,a1
  7920.     bsr    gab
  7921.     move.b    d0,d4
  7922.     beq.s    bb1
  7923.     clr.b    -1(a0)
  7924.     cmp.b    #".",d0        ;day.month.year
  7925.     bne.s    dat2
  7926. bb1    bsr    convert_ASCII_to_num
  7927.     cmp.w    #99,d0    ;rough check
  7928.     bhi    muell
  7929.     move.w    d0,(a2)+
  7930.     tst.l    d1
  7931.     beq    muell
  7932.     tst.b    d4
  7933.     dbeq    d3,aa1
  7934. mull1    tst.w    d3
  7935.     bne    muell
  7936.     lea    temp2buf(a5),a2
  7937.     move.l    temp1(a5),a1
  7938.     moveq    #2,d3
  7939. .B    move.w    (a2)+,(a1)+
  7940.     dbra    d3,.B
  7941.     bra    oktt
  7942. aa2    move.l    a0,a1
  7943.     bsr    gab
  7944.     move.b    d0,d4
  7945.     beq.s    bb2
  7946.     clr.b    -1(a0)
  7947. dat2    cmp.b    #":",d0        ;hour:minute:second
  7948.     bne.s    dat3
  7949. bb2    bsr    convert_ASCII_to_num
  7950.     cmp.w    #99,d0
  7951.     bhi    muell
  7952.     move.w    d0,(a2)+
  7953.     tst.l    d1
  7954.     beq    muell
  7955.     tst.b    d4
  7956.     dbeq    d3,aa2
  7957. mull2    tst.w    d3
  7958.     bne    muell
  7959.     lea    temp2buf(a5),a2
  7960.     move.l    temp1(a5),a1
  7961.     lea    6(a1),a1
  7962.     moveq    #2,d3
  7963. .B    move.w    (a2)+,(a1)+
  7964.     dbra    d3,.B
  7965.     bra    oktt
  7966.     moveq    #2,d3
  7967. aa3    move.l    a0,a1
  7968.     bsr    gab
  7969.     move.b    d0,d4
  7970.     beq.s    bb3
  7971.     clr.b    -1(a0)
  7972. dat3    cmp.b    #"-",d0        ;month-day-year
  7973.     bne    muell
  7974. bb3    bsr    convert_ASCII_to_num
  7975.     cmp.w    #99,d0
  7976.     bhi    muell
  7977.     move.w    d0,(a2)+
  7978.     tst.l    d1
  7979.     beq    muell
  7980.     tst.b    d4
  7981.     dbeq    d3,aa3
  7982. mull3    tst.w    d3
  7983.     bne    muell
  7984.     lea    temp2buf(a5),a2
  7985.     move.l    temp1(a5),a1
  7986.     move.w    (a2)+,2(a1)
  7987.     move.w    (a2)+,(a1)
  7988.     move.w    (a2)+,4(a1)
  7989. oktt    tst.l    (a4)
  7990.     bne    settim
  7991.     lea    chaotab(pc),a0
  7992.     move.l    temp1(a5),a1
  7993.     lea    temp2buf(a5),a3
  7994.     moveq    #5,d0
  7995.     moveq    #0,d1
  7996. .A    move.b    (a0)+,d1
  7997.     move.w    0(a1,d1),d2
  7998.     move.b    d2,(a3)+
  7999.     dbra    d0,.A
  8000.     lea    temp2buf(a5),a3
  8001.     bsr    calcsec
  8002.     movem.l    (sp)+,d1-d4/a0-a4
  8003.     moveq    #RETURN_OK,d0
  8004.     rts    ;result in d5-d7
  8005.  
  8006. muell    lea    muell_tx(pc),a1
  8007.     bsr    pr_stringlf
  8008.     movem.l    (sp)+,d1-d4/a0-a4
  8009.     moveq    #RETURN_ERROR,d0
  8010.     rts
  8011.  
  8012. gab    move.b    (a0)+,d0
  8013.     cmp.b    #$30,d0
  8014.     blo.s    .A
  8015.     cmp.b    #$39,d0
  8016.     bls.s    gab
  8017. .A    cmp.b    #"%",d0    ;handle bin (that's fun !)
  8018.     beq.s    gab
  8019.     rts
  8020.  
  8021. ** GET TIME STORE DAYS,MINUTES,TICKS AT A0
  8022. get_time    move.l    a0,-(sp)
  8023.     move.l    a0,d1
  8024.     jsr    _LVODateStamp(a6)
  8025.     move.l    (sp)+,a0
  8026.     rts
  8027.  
  8028. ** ENTRY A0 pts to 7 words of storage, A1 pts to date stamp
  8029. ** send time to A0 --> 13(A0)
  8030. convert_time
  8031.     movem.l    d0-d3/a0-a2,-(sp)
  8032.     move.l    ds_Tick(a1),d0
  8033.     divu    #50,d0
  8034.     move.w    d0,4+6(a0)        seconds
  8035.     swap    d0
  8036.     asl.w    #1,d0
  8037.     move.w    d0,6+6(a0)        hundredths
  8038.     move.l    ds_Minute(a1),d0
  8039.     divu    #60,d0
  8040.     move.w    d0,0+6(a0)        hours
  8041.     swap    d0    
  8042.     move.w    d0,2+6(a0)        minutes
  8043.     move.l    ds_Days(a1),d0
  8044.     move.w    #365,d1        V2.0:year, day, month
  8045.     move.w    #77,d2
  8046. wdhj    addq.w    #1,d2
  8047.     sub.w    d1,d0
  8048.     bcs.s    mon
  8049.     move.w    d2,d3
  8050.     and.w    #3,d3
  8051.     bne.s    wdhj
  8052.     cmp.w    #100,d2
  8053.     blo.s    ork
  8054.     moveq    #1,d3
  8055.     addq.w    #1,d0
  8056.     sub.w    #100,d2
  8057. ork    subq.w    #1,d0
  8058.     bcc.s    wdhj
  8059.     addq.w    #1,d0
  8060. mon    add.w    d1,d0
  8061.     move.w    d2,4(a0)    year (lots of work)
  8062.     moveq    #0,d2
  8063.     lea    montab(pc),a2
  8064. wdhm    addq.w    #1,d2
  8065.     moveq    #0,d1
  8066.     move.b    (a2)+,d1
  8067.     sub.w    d1,d0
  8068.     bcs.s    tag
  8069.     cmp.w    #2,d2
  8070.     bne.s    wdhm
  8071.     move.w    4(a0),d3
  8072.     beq.s    wdhm
  8073.     and.w    #3,d3
  8074.     bne.s    wdhm
  8075.     subq.w    #1,d0
  8076.     bcc.s    wdhm
  8077.     addq.w    #1,d0
  8078. tag    add.w    d1,d0
  8079.     addq.w    #1,d0
  8080.     move.w    d2,2(a0)    month (i don't like february)
  8081.     move.w    d0,(a0)        day
  8082.     movem.l    (sp)+,d0-d3/a0-a2
  8083.     rts
  8084.  
  8085. montab    dc.b    31,28,31,30,31,30,31,31,30,31,30,31
  8086.  
  8087. *************************
  8088. *    STACK        *
  8089. *************************
  8090. stackz    move.l    CLIptr(a5),a4
  8091.     move.l    cli_DefaultStack(a4),d7
  8092.     lsl.l    #2,d7
  8093.     tst.l    parm2(a5)
  8094.     beq.s    show_stack
  8095.     move.l    parm2(a5),a1
  8096.     bsr    convert_ASCII_to_num
  8097.     beq    bad_number_error
  8098. stk_num_OK
  8099.     move.l    d0,d6
  8100.     cmpi.l    #1600,d6  ;allow 1600 bytes for DOS
  8101.     blt.s    stoosmall
  8102.     move.l    d6,d0
  8103.     moveq    #1,d1   
  8104.     bsr    iwantmem 
  8105.     beq.s    stoobig   
  8106.     move.l    d0,a1   
  8107.     move.l    d6,d0   
  8108.     bsr    givemem  
  8109.     
  8110.     lsr.l    #2,d6
  8111.     move.l    d6,cli_DefaultStack(a4)
  8112.     moveq    #RETURN_OK,d0
  8113.     rts
  8114. stoosmall
  8115.     lea    stk_too_small_tx(pc),a1
  8116.     moveq    #RETURN_ERROR,d0
  8117.     bra    pr_string
  8118. stoobig
  8119.     moveq    #103,d0
  8120.     bra    pr_galactic
  8121. show_stack
  8122.     move.l    d7,-(sp)
  8123.     lea    (sp),a1
  8124.     lea    stk_size_tx(pc),a0
  8125.     bsr    new_print
  8126.     move.l    (sp)+,d0
  8127.     moveq    #RETURN_OK,d0
  8128.     rts
  8129.  
  8130. ** CHECK STRING A0 IF ENDING IN :
  8131. ** RETURN EQ IF DOES END IN COLON
  8132. check_for_colon
  8133. .A    tst.b    (a0)+    MAKE SURE ENDS IN :
  8134.     bne.s    .A
  8135.     move.b    -2(a0),d0
  8136.     cmp.b    #':',d0
  8137.     rts
  8138.  
  8139. do_forbid    move.l    4.w,a6
  8140.     jsr    _LVOForbid(a6)
  8141.     move.l    dosbase(a5),a6
  8142.     rts
  8143. do_permit    move.l    4.w,a6
  8144.     jsr    _LVOPermit(a6)
  8145.     move.l    dosbase(a5),a6
  8146.     rts
  8147.     
  8148. *************************
  8149. *    ASSIGN         *
  8150. *************************
  8151. assignz    cmp.w    #36,kickver(a5)
  8152.     blo    assi13
  8153.     tst.l    parm2(a5)
  8154.     beq    assi13
  8155.     move.l    parm3(a5),d2
  8156.     beq    too_less_args
  8157.     move.l    parm2(a5),a2
  8158.     move.l    a2,a0
  8159.     bsr    check_for_colon
  8160.     bne.s    .G
  8161.     clr.b    -2(a0)    no colon-end
  8162. .G    lea    assignuse(pc),a1
  8163.     move.l    parm4(a5),d0
  8164.     bne.s    .B
  8165.     move.l    d2,a0
  8166.     bsr    CheckOpt
  8167.     beq.s    .C
  8168.     move.l    d2,d1        Assign LOCK
  8169.     moveq    #-2,d2
  8170.     jsr    _LVOLock(a6)
  8171.     move.l    d0,d7
  8172.     move.l    d0,d2
  8173.     beq    DOSerr
  8174.     move.l    a2,d1
  8175.     jsr    _LVOAssignLock(a6)
  8176.     tst.l    d0
  8177.     beq    DOSerrUL
  8178.     bra    .A
  8179. .C    move.l    a2,d1        Assign REMOVE
  8180.     moveq    #0,d2
  8181.     jsr    _LVOAssignLock(a6)
  8182.     tst.l    d0
  8183.     beq    DOSerr
  8184.     bra.s    .A
  8185.  
  8186. .B    move.l    d0,a0
  8187.     bsr    CheckOpt
  8188.     bne.s    .H
  8189.     move.l    d2,d1        Assign REMOVE part
  8190.     moveq    #-2,d2
  8191.     jsr    _LVOLock(a6)
  8192.     move.l    d0,d7
  8193.     move.l    d0,d2
  8194.     beq    DOSerr
  8195.     move.l    a2,d1
  8196.     jsr    _LVORemAssignList(a6)
  8197.     tst.l    d0
  8198.     beq    DOSerrUL
  8199.     bra.s    .A
  8200. .H    bsr    CheckOpt
  8201.     bne.s    .D
  8202.     move.l    d2,d1        Assign ADD
  8203.     moveq    #-2,d2
  8204.     jsr    _LVOLock(a6)
  8205.     move.l    d0,d7
  8206.     move.l    d0,d2
  8207.     beq    DOSerr
  8208.     move.l    a2,d1
  8209.     jsr    _LVOAssignAdd(a6)
  8210.     tst.l    d0
  8211.     beq    DOSerrUL
  8212.     bra.s    .A
  8213. .D    bsr    CheckOpt
  8214.     bne.s    .E
  8215.     move.l    a2,d1        Assign PATH
  8216.     jsr    _LVOAssignPath(a6)
  8217.     tst.l    d0
  8218.     beq    DOSerr
  8219.     bra.s    .A
  8220. .E    bsr    CheckOpt
  8221.     bne.s    .F
  8222.     move.l    a2,d1        Assign DEFER
  8223.     jsr    _LVOAssignLate(a6)
  8224.     tst.l    d0
  8225.     beq    DOSerr
  8226.     bra.s    .A
  8227. .F    lea    assignuse(pc),a1
  8228.     bsr    pr_stringlf
  8229. .A    moveq    #RETURN_OK,d0
  8230.     rts
  8231.  
  8232. assi13    bsr    do_forbid        FORBID
  8233.     bsr    get_first_devinfo
  8234.     tst.l    parm2(a5)
  8235.     beq    show_assigns
  8236.     tst.l    parm3(a5)
  8237.     beq    exit_assignf    ONLY TWO PARMS TYPED (NEED 3)
  8238.     move.l    parm2(a5),a0
  8239.     bsr    check_for_colon
  8240.     beq    assi14
  8241.     bsr    do_permit
  8242. no_col    move.l    #210,d0
  8243.     bra    pr_galactic
  8244.     
  8245. assi14    moveq    #dlt_directory,d1    CREATE/MODIFY ASSIGN ******
  8246.     bsr    find_next_assign
  8247.     tst.l    d0
  8248.     bne    no_more_dir_assigns
  8249.     move.l    a0,d5
  8250.     move.l    parm2(a5),a0    A0=assigned name[0]
  8251.     moveq    #0,d2
  8252.     move.b    (a1)+,d2        get char count
  8253. .A    move.b    (a1)+,d0
  8254.     move.b    (a0)+,d1
  8255.     beq.s    assi14
  8256.     subq.l    #1,d2
  8257.     bmi.s    .C
  8258.     bsr    compD1D0nocase
  8259.     beq.s    .A
  8260. .D    bra.s    assi14
  8261.  
  8262. .C    cmp.b    #':',d1    CHANGE EXISTING
  8263.     bne.s    .D
  8264.     bsr    do_permit        PERMIT
  8265.     move.l    d5,a2        GOT A MATCH
  8266.     moveq    #ACCESS_READ,d2
  8267.     move.l    parm3(a5),d1
  8268.     jsr    _LVOLock(a6)
  8269.     tst.l    d0
  8270.     beq    exit_assignp
  8271.     move.l    d0,a3
  8272.     bsr    do_forbid        FORBID
  8273.     move.l    dvi_Lock(a2),d4
  8274.     move.l    a3,dvi_Lock(a2)    new lock
  8275.     add.l    a3,a3
  8276.     add.l    a3,a3
  8277.     move.l    fl_Task(a3),dvi_Task(a2)
  8278.     clr.l    dvi_Handler(a2)
  8279.     clr.l    dvi_StackSize(a2)
  8280.     clr.l    dvi_Priority(a2)
  8281.     clr.l    dvi_Startup(a2)
  8282.     clr.l    dvi_SegList(a2)
  8283.     clr.l    dvi_GlobVec(a2)
  8284.     bsr    do_permit
  8285.     move.l    d4,d1
  8286.     jsr    _LVOUnLock(a6)
  8287.     bra    exit_assignp
  8288.     
  8289. no_more_dir_assigns
  8290.     bsr    do_permit        CREATE NEW ASSIGN
  8291.     moveq    #48,d0
  8292.     move.l    #MEMF_CLEAR+1,d1
  8293.     bsr    iwantmem
  8294.     beq    exit_assignp
  8295.     move.l    d0,a4
  8296.     move.l    #48,(a4)+        save size byte
  8297.     move.l    parm2(a5),a0
  8298.     moveq    #4,d0    4+1 extra bytes for dos(nb: : is ignored)
  8299. .A    addq.l    #1,d0
  8300.     tst.b    (a0)+
  8301.     bne.s    .A
  8302.     move.l    d0,d3    D3=size+5+1    (block size|char_count|chars)
  8303.     moveq    #1,d1
  8304.     bsr    iwantmem
  8305.     beq    rem_dvi
  8306.     move.l    d0,a3
  8307.     move.l    d0,d4        D4=string ptr
  8308.     move.l    d3,(a3)+        save size byte
  8309.     subq.l    #6,d3
  8310.     move.b    d3,(a3)+        save char_count
  8311.     move.l    parm2(a5),a0
  8312.     bra.s    .C
  8313. .B    move.b    d1,(a3)+        copy string to NAME
  8314. .C    move.b    (a0)+,d1
  8315.     cmp.b    #':',d1
  8316.     bne.s    .B
  8317.     clr.b    (a3)        ;NULL-ending V2.0
  8318.     addq.l    #4,d0
  8319.     lsr.l    #2,d0    convert to bstr
  8320.     move.l    d0,dvi_Name(a4)
  8321.     move.l    #dlt_directory,dvi_Type(a4)
  8322.     moveq    #ACCESS_READ,d2
  8323.     move.l    parm3(a5),d1
  8324.     jsr    _LVOLock(a6)
  8325.     tst.l    d0
  8326.     beq    rem_str
  8327.     move.l    d0,dvi_Lock(a4)
  8328.     lsl.l    #2,d0        x 4
  8329.     move.l    d0,a0
  8330.     move.l    fl_Task(a0),dvi_Task(a4)
  8331.     bsr    do_forbid
  8332.     bsr    get_first_devinfo    RETURNS A1 pts info substr, A2 pts 1st devinfo
  8333.     move.l    a2,dvi_Next(a4)
  8334.     move.l    a4,d0
  8335.     lsr.l    #2,d0
  8336.     move.l    d0,di_DevInfo(a1)    Insert new top of chain
  8337.     bsr    do_permit
  8338.     
  8339.     bra.s    exit_assignp
  8340. rem_str    move.l    d4,a1
  8341.     move.l    (a1),d0
  8342.     bsr    givemem
  8343. rem_dvi    lea    -4(a4),a1
  8344.     moveq    #48,d0
  8345.     bsr    givemem
  8346. exit_assignp
  8347.     moveq    #RETURN_OK,d0
  8348.     rts
  8349. exit_assignf
  8350.     bsr    do_permit
  8351.     moveq    #RETURN_OK,d0
  8352.     rts
  8353.     
  8354. * SHOW ASSIGNS    ALREADY IN FORBID STATE
  8355. show_assigns
  8356.     lea    -8(sp),sp
  8357.     move.l    a2,(sp)        0(sp)= BPTR of first devinfo
  8358.     move.l    #5000,d0
  8359.     moveq    #1,d1
  8360.     bsr    iwantmem        allocate big block
  8361.     beq    asg_fail
  8362.     move.l    d0,a4        A4 = string block
  8363.     move.l    d0,a3
  8364.     add.l    #5000,a3    A3 = end of string block
  8365.     move.l    d0,4(sp)        4(sp) = string block
  8366.     lea    volume_tx(pc),a0    PRINT VOLUMES:
  8367.     bsr    copy_name
  8368.     moveq    #dlt_volume,d1
  8369. do_volumes
  8370. .E    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8371.     tst.l    d0         TO THE BIG STRING
  8372.     bne.s    do_devices
  8373.     bsr    copy_bstr
  8374.     move.b    #$20,(a4)+    seperate with spaces
  8375.     tst.l    dvi_Task(a0)
  8376.     beq.s    .H
  8377.     lea    mounted_tx(pc),a0
  8378.     bsr    copy_name
  8379. .H    move.b    #LF,(a4)+
  8380.     bra.s    .E
  8381. do_devices    
  8382.     move.l    (sp),a2        restart at first devinfo
  8383.     lea    device_tx(pc),a0    PRINT DEVICES:
  8384.     bsr    copy_name
  8385.     moveq    #dlt_device,d1
  8386. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8387.     tst.l    d0         TO THE BIG STRING
  8388.     bne.s    .A
  8389.     bsr    copy_bstr
  8390.     move.b    #$20,(a4)+    seperate with spaces
  8391.     move.b    #$20,(a4)+
  8392.     bra.s    .B
  8393. .A    move.b    #LF,(a4)+    linefeed at end
  8394.     move.l    (sp),a2
  8395. do_late
  8396.     lea    assign_tx(pc),a0    PRINT DIRECTORIES
  8397.     bsr    copy_name
  8398.     moveq    #dlt_late,d1
  8399. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8400.     tst.l    d0         TO THE BIG STRING
  8401.     bne.s    .A
  8402.     bsr    copy_bstr
  8403.     move.b    #":",(a4)+
  8404.     move.b    #9,(a4)+    seperate with tab
  8405.     move.b    #"<",(a4)+
  8406.     move.l    dvi_Handler(a0),a0
  8407.     bsr    copy_name
  8408.     move.b    #">",(a4)+
  8409.     move.b    #LF,(a4)+    linefeed at end
  8410.     bra.s    .B
  8411. .A    move.l    (sp),a2
  8412. do_nonbind
  8413.     moveq    #dlt_nonbind,d1
  8414. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8415.     tst.l    d0         TO THE BIG STRING
  8416.     bne.s    .A
  8417.     bsr    copy_bstr
  8418.     move.b    #":",(a4)+
  8419.     move.b    #9,(a4)+    seperate with tab
  8420.     move.b    #"[",(a4)+
  8421.     move.l    dvi_Handler(a0),a0
  8422.     bsr    copy_name
  8423.     move.b    #"]",(a4)+
  8424.     move.b    #LF,(a4)+    linefeed at end
  8425.     bra.s    .B
  8426. .A    move.l    (sp),a2
  8427. do_dirs        ;uses top of big mem block (end in a3)
  8428.     move.w    #-1,-(a3)    push negative
  8429. .G    moveq    #dlt_directory,d1
  8430.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  8431.     tst.l    d0         TO THE BIG STRING
  8432.     bne.s    .E
  8433.     clr.l    -(a3)        null-end locks
  8434.     cmp.w    #36,kickver(a5)
  8435.     blo.s    .A        OS1.3-: no assign add
  8436.     move.l    dvi_LockList(a0),d0    search locklist (assign add)
  8437.     beq.s    .A
  8438. .B    move.l    d0,a1
  8439.     move.l    4(a1),-(a3)    push locks
  8440.     move.l    (a1),d0
  8441.     bne.s    .B
  8442. .A    move.l    d2,-(a3)    push main lock
  8443.     clr.b    -(a3)        null-end name
  8444.     move.l    dvi_Name(a0),a1
  8445.     add.l    a1,a1
  8446.     add.l    a1,a1
  8447.     moveq    #0,d0
  8448.     move.b    (a1),d0        name-length
  8449.     btst    #0,d0
  8450.     bne.s    .C
  8451.     clr.b    -(a3)        for word-align
  8452. .C    add.l    d0,a1
  8453.     addq.l    #1,a1        a3=end of name
  8454.     bra.s    .D
  8455. .F    move.b    -(a1),-(a3)
  8456. .D    dbra    d0,.F
  8457.     bra.s    .G
  8458.  
  8459. .E    bsr    do_permit
  8460. get_nxt_lock
  8461.     cmp.b    #$ff,(a3)    check for end
  8462.     beq.s    .A
  8463.     move.l    a3,a0
  8464.     bsr    copy_name    copy assign-name
  8465. .B    tst.b    (a3)+        look for end
  8466.     bne.s    .B
  8467.     move.b    #9,(a4)+    copy tab
  8468.     move.l    a3,d0
  8469.     addq.l    #1,d0
  8470.     and.w    #$fffe,d0    word-align
  8471.     move.l    d0,a3
  8472.     move.l    (a3)+,d1    first lock
  8473.     beq.s    .F
  8474.     bra.s    .G
  8475. .C    move.l    (a3)+,d1
  8476.     beq.s    get_nxt_lock
  8477.     move.b    #9,(a4)+    other locks are assign adds
  8478.     move.b    #"+",(a4)+
  8479.     move.b    #" ",(a4)+
  8480. .G    move.l    d1,a0
  8481.     add.l    a0,a0
  8482.     add.l    a0,a0
  8483.     move.l    fl_Volume(a0),a0
  8484.     add.l    a0,a0
  8485.     add.l    a0,a0
  8486.     tst.l    dvi_Task(a0)    check for mounted
  8487.     bne.s    .E
  8488. .F    lea    unmounted_tx(pc),a0
  8489.     bsr    copy_name
  8490.     bra.s    get_nxt_lock
  8491. .E    jsr    _LVODupLock(a6)    copy lock(D1) --> (D0)
  8492.     tst.l    d0
  8493.     beq.s    .F        could not dup lock
  8494.     move.l    a4,a0
  8495.     move.l    a3,-(sp)
  8496.     bsr    eval_full_path    write path to big block
  8497.     move.l    (sp)+,a3
  8498.     jsr    _LVOUnLock(a6)
  8499. .D    tst.b    (a4)+        look for end
  8500.     bne.s    .D
  8501.     move.b    #LF,-1(a4)    overwrite null or tab
  8502.     bra.s    .C
  8503. .A    clr.b    (a4)        null-end
  8504.  
  8505.     move.l    a4,d6
  8506.     subq.l    #1,d6
  8507.     move.l    4(sp),a4
  8508.     bsr    rawh_off
  8509.     bsr    pr_screen
  8510.     move.l    4(sp),a1
  8511.     move.l    #5000,d0
  8512.     bsr    givemem
  8513.     bra.s    asg_fail2
  8514. asg_fail    bsr    do_permit
  8515. asg_fail2    lea    8(sp),sp
  8516.     moveq    #RETURN_OK,d0
  8517.     rts
  8518.  
  8519.  
  8520. get_first_devinfo
  8521.     move.l    dl_Root(a6),a1
  8522.     move.l    rn_Info(a1),a1
  8523.     add.l    a1,a1
  8524.     add.l    a1,a1
  8525.     move.l    di_DevInfo(a1),a2    A2=BPTR to first devinfo
  8526.     rts
  8527.  
  8528. copy_name    move.b    (a0)+,(a4)+
  8529.     bne.s    copy_name
  8530.     lea    -1(a4),a4
  8531.     rts
  8532.  
  8533. **COPY BSTR FROM A1 TO A4, DONT NULL END
  8534. copy_bstr    move.b    (a1)+,d0
  8535.     bra.s    .C
  8536. .B    move.b    (a1)+,(a4)+
  8537. .C    dbra    d0,.B
  8538.     rts
  8539.     
  8540. **ENTRY: D1=type ,A2=Bptr of devinfo, EXIT: A2=Bptr to next ,D0=0 if found
  8541. **EXIT: D2=lock, D1=type, A1 pts to string, A0 pts devinfo struct
  8542. find_next_assign
  8543. .A    add.l    a2,a2    FIND NEXT DEVINFO THAT MATCHES THE TYPE (D1)
  8544.     add.l    a2,a2        A2 pts to first devinfo structure
  8545.     move.l    a2,d0        tst.l    (a2)
  8546.     beq.s    .B
  8547.     move.l    a2,a0
  8548.     move.l    dvi_Name(a2),a1
  8549.     move.l    dvi_Lock(a2),d2
  8550.     move.l    dvi_Type(a2),d0
  8551.     move.l    (a2),a2
  8552.     cmp.l    d0,d1
  8553.     bne.s    .A
  8554.     add.l    a1,a1
  8555.     add.l    a1,a1
  8556.     moveq    #0,d0
  8557.     rts
  8558. .B    moveq    #1,d0
  8559.     rts
  8560.  
  8561. bad_number_error
  8562.     movem.l    a0-a1,-(sp)
  8563.     cmp.w    #36,kickver(a5)
  8564.     blo.s    .A
  8565.     moveq    #115,d0
  8566.     bsr    pr_DOSerr
  8567.     bra.s    .B
  8568. .A    lea    bad_number_tx(pc),a1
  8569.     bsr    pr_stringlf
  8570. .B    movem.l    (sp)+,a0-a1
  8571.     moveq    #RETURN_ERROR,D0
  8572.     rts
  8573.  
  8574. *************************
  8575. *    FAILAT         *
  8576. *************************
  8577. failatz    move.l    parm2(a5),d0
  8578.     beq.s    .A
  8579.     move.l    d0,a1
  8580.     bsr    convert_ASCII_to_num
  8581.     beq.s    bad_number_error
  8582.     move.l    CLIptr(a5),a0
  8583.     move.l    d0,cli_FailLevel(a0)
  8584.     bra.s    .B
  8585. .A    move.l    CLIptr(a5),a0
  8586.     lea    cli_FailLevel(a0),a1
  8587.     lea    failat_tx(pc),a0
  8588.     bsr    new_print
  8589. .B    moveq    #RETURN_OK,d0
  8590.     rts
  8591.  
  8592. *************************
  8593. *    IF         *
  8594. *************************
  8595. ifz    move.b    #$ff,if_flag(a5)
  8596.     move.b    #$ff,if_condition(a5)    set FALSE
  8597.     lea    parm2(a5),a4
  8598.     moveq    #0,d4        not state
  8599. .C    move.l    (a4)+,d0
  8600.     beq    if_fail
  8601.     move.l    d0,a0
  8602.     lea    not_tx(pc),a1
  8603.     bsr    compare_strings
  8604.     bne.s    .B
  8605.     not.b    d4        set D4=FF if not
  8606.     bra    .C
  8607. .B    lea    exists_tx(pc),a1
  8608.     bsr    compare_strings
  8609.     bne.s    try_warn    IF NOT AN EXISTS TYPE COMPARE
  8610.     move.l    (a4)+,d1
  8611.     beq    if_fail
  8612.     moveq    #0,d3        d3=0    doesnt exist
  8613.     moveq    #ACCESS_READ,d2
  8614.     jsr    _LVOLock(a6)
  8615.     tst.l    d0
  8616.     beq.s    save_state
  8617.     move.l    d0,d1
  8618.     jsr    _LVOUnLock(a6)
  8619.     not.b    d3        d3=ff    exists
  8620. save_state
  8621.     not.b    d3        d3=0    true
  8622.     eor.b    d4,d3
  8623.     move.b    d3,if_condition(a5)
  8624.     moveq    #RETURN_OK,D0
  8625.     RTS
  8626. try_warn    move.l    last_failcode(a5),d5
  8627.     moveq    #RETURN_WARN,d6
  8628.     lea    warn_tx(pc),a1    CHECK IF 'IF WARN'
  8629.     bsr    compare_strings
  8630.     bne    try_error
  8631. set_error_state
  8632.     moveq    #0,d3
  8633.     cmp.l    d6,d5
  8634.     bne    save_state
  8635.     not.b    d3
  8636.     bra    save_state
  8637. try_error    lea    error_tx(pc),a1
  8638.     bsr    compare_strings
  8639.     bne    try_fail
  8640.     moveq    #RETURN_ERROR,d6
  8641.     bra    set_error_state
  8642. try_fail    lea    fail_tx(pc),a1
  8643.     bsr    compare_strings
  8644.     bne    if_fail
  8645.     moveq    #RETURN_FAIL,d6
  8646.     bra    set_error_state
  8647. if_fail    not.b    if_flag(a5)    clear it
  8648.     lea    if_error_tx(pc),a1
  8649.     bsr    pr_string
  8650.     MOVEQ    #RETURN_ERROR,D0
  8651.     RTS
  8652.  
  8653. *************************
  8654. *    ASK         *
  8655. *************************
  8656. askz    bsr    echoz        print the parm same as echo does
  8657. rask    bsr    raw_off
  8658.     move.l    stdin(a5),d1
  8659.     beq.s    .A
  8660.     lea    tempbuf(a5),a4    a4:tempbuf
  8661.     clr.b    (a4)
  8662.     move.l    a4,d2
  8663.     moveq    #120,d3
  8664.     jsr    _LVORead(a6)    read input
  8665.     tst.l    d0
  8666.     bmi.s    .A
  8667.     beq.s    .A
  8668.     move.l    outhandle(a5),d1
  8669.     cmp.l    stdout(a5),d1    output redirected ?
  8670.     beq.s    .C
  8671.     move.l    a4,a0
  8672.     add.l    d0,a0
  8673.     subq.l    #1,a0
  8674.     clr.b    (a0)    Null-End
  8675.     move.l    a4,a1
  8676.     bsr    pr_string    repeat input
  8677.     bra    .A
  8678. .C    or.b    #$20,(a4)
  8679.     moveq    #RETURN_FAIL,d0
  8680.     cmp.b    #'f',(a4)    V2.0
  8681.     beq    .B
  8682.     moveq    #RETURN_ERROR,d0
  8683.     cmp.b    #'e',(a4)    V2.0
  8684.     beq    .B
  8685.     moveq    #RETURN_WARN,d0
  8686.     cmp.b    #'j',(a4)    V2.0
  8687.     beq    .B
  8688.     cmp.b    #'y',(a4)
  8689.     beq    .B
  8690. .A    moveq    #RETURN_OK,D0
  8691. .B    rts
  8692.  
  8693. *************************
  8694. *    WAIT         *
  8695. *************************
  8696. waitz    move.l    parm2(a5),d0
  8697.     beq    too_less_args
  8698.     move.l    d0,a1
  8699.     bsr    convert_ASCII_to_num
  8700.     beq    bad_number_error
  8701.     move.l    d0,d4
  8702.     lsl.l    #2,d4        d4*4
  8703.     add.l    d0,d4        d4:=d0*5 (d4*4+d4)
  8704. .C    bsr    check_c
  8705.     bne.s    .E
  8706.     moveq    #LF,d1        1/5 second
  8707.     jsr    _LVODelay(a6)
  8708.     subq.l    #1,d4
  8709.     bne.s    .C
  8710. .E    moveq    #RETURN_OK,D0
  8711.     RTS
  8712.  
  8713. *************************
  8714. *    QUIT         *
  8715. *************************
  8716. * only returns from script files.
  8717. quitz    tst.b    scflag(a5)
  8718.     bne.s    .A
  8719.     moveq    #RETURN_OK,D0
  8720.     RTS
  8721. .A    move.l    parm2(a5),d0
  8722.     beq    .B
  8723.     move.l    d0,a1
  8724.     bsr    convert_ASCII_to_num
  8725.     bne    .B
  8726.     bsr    bad_number_error
  8727. .B    move.l    d0,-(sp)
  8728.     bsr    kill_script    guarantee that script is dead
  8729.     move.l    (sp)+,d0
  8730.     rts
  8731.     
  8732. *************************
  8733. *    HTYPE         *
  8734. *************************
  8735. htypez    move.l    parm2(a5),d1
  8736.     beq    too_less_args
  8737.     move.l    d1,a0
  8738.     bsr    readfile
  8739.     move.l    d0,mem_addr(a5)
  8740.     move.l    d0,mem_offset_addr(a5)
  8741.     move.l    d1,temp1(a5)
  8742.     add.l    d0,d1
  8743.     move.l    d1,d7        end marker
  8744.     bsr    rawh_off
  8745. .B    bsr    check_c
  8746.     bne    htype_end
  8747.     bsr    show_16_locs
  8748.     cmp.l    mem_addr(a5),d7
  8749.     bhi    .B
  8750. htype_end    move.l    mem_offset_addr(a5),a1
  8751.     move.l    temp1(a5),d0
  8752.     bsr    givemem
  8753.     moveq    #RETURN_OK,D0
  8754.     RTS
  8755.  
  8756. *************************
  8757. *    STRINGS     *
  8758. *************************
  8759. stringsz    move.l    parm2(a5),d0
  8760.     beq    too_less_args
  8761.     moveq    #7,d7        default 7
  8762.     move.l    parm3(a5),d0
  8763.     beq.s    .B
  8764.     move.l    d0,a1
  8765.     bsr    convert_ASCII_to_num
  8766.     beq    bad_number_error
  8767.     
  8768.     move.l    d0,d7        D7=min_string
  8769. .B    move.l    parm2(a5),a0
  8770.     bsr    readfile
  8771.     move.l    d0,a4        A4=addr of file
  8772.     move.l    a4,a3
  8773.     move.l    d1,d6        D6=size of file
  8774.     add.l    d0,d1
  8775.     move.l    d1,d4        D4=max addr
  8776.     movem.l    d4-d7/a3-a4,-(sp)
  8777.     bsr    rawh_off
  8778.     movem.l    (sp)+,d4-d7/a3-a4
  8779. str_next    bsr    check_c
  8780.     bne    kill_string_file
  8781.     moveq    #0,d5        D5=current string size
  8782.     move.l    a3,a2
  8783. valid_ch    cmp.l    a3,d4
  8784.     beq    string_fin
  8785.     move.b    (a3)+,d0
  8786.     cmp.b    #' ',d0
  8787.     blo.s    not_valid_char
  8788.     cmp.b    #$7f,d0
  8789.     bhi.s    not_valid_char
  8790.     addq.l    #1,d5
  8791.     bra    valid_ch
  8792. not_valid_char
  8793.     cmp.l    d7,d5
  8794.     blo    str_next
  8795.     bsr    write_my_string
  8796.     bra    str_next
  8797.  
  8798. string_fin
  8799.     cmp.l    d7,d5
  8800.     blo    kill_string_file
  8801.     bsr    write_my_string
  8802. kill_string_file
  8803.     move.l    a4,a1
  8804.     move.l    d6,d0
  8805.     bsr    givemem
  8806.     moveq    #RETURN_OK,D0
  8807.     RTS
  8808.     
  8809. write_my_string
  8810.     move.l    outhandle(a5),d1
  8811.     beq.s    .A
  8812.     move.l    a2,d2
  8813.     move.l    d5,d3
  8814.     jsr    _LVOWrite(a6)
  8815. .A    bra    pr_lf
  8816.  
  8817. *************************
  8818. *    FILENOTE    *
  8819. *************************
  8820. filenotez bsr    fixpam32        V2.0
  8821.     move.l    a0,d1
  8822.     move.l    a1,d2
  8823.     move.l    a1,a2
  8824.     moveq    #78,d0
  8825. .A    tst.b    (a2)+
  8826.     beq.s    fnok
  8827.     dbra    d0,.A
  8828.     moveq    #RETURN_ERROR,d0    ;more than 80 chars
  8829.     rts
  8830. fnok    jsr    _LVOSetComment(a6)
  8831.     addq.l    #1,d0
  8832.     bne    DOSerr
  8833.     rts
  8834.  
  8835. *************************
  8836. *    SEARCH        *    Searches a string in a file
  8837. *************************
  8838. searchz    bsr    rawh_off        V2.0
  8839.     bsr    fixpam32
  8840.     tst.b    (a1)
  8841.     beq    too_less_args
  8842.     move.l    a1,d7
  8843.     bsr    readfile    get file
  8844.     move.l    d1,d5        push size
  8845.     move.l    d0,d6
  8846.     add.l    d1,d6
  8847.     move.l    d0,a2
  8848.     move.l    d0,a3        a3:start of file
  8849. .A    move.l    d7,a1        d7:search string
  8850.     move.l    d6,a0        d6:end of file
  8851.     bsr    searchSTR    a2:current searchpos
  8852.     cmp.b    #1,d0
  8853.     beq.s    .B
  8854.     move.l    a0,-(sp)
  8855.     move.l    d7,a0
  8856.     moveq    #-1,d4
  8857. .D    addq.l    #1,d4
  8858.     tst.b    (a0)+        length of searchstr.
  8859.     bne.s    .D
  8860.     move.l    a1,d2
  8861.     move.l    a2,d3
  8862.     sub.l    d2,d3
  8863.     beq.s    .C
  8864.     move.l    outhandle(a5),d1
  8865.     jsr    _LVOWrite(a6)    write part before searchstr.
  8866. .C    lea    farb3(pc),a1
  8867.     bsr    pr_string
  8868.     move.l    a2,d2
  8869.     move.l    d4,d3
  8870.     move.l    outhandle(a5),d1
  8871.     jsr    _LVOWrite(a6)    write searchstr.
  8872.     lea    farb1(pc),a1
  8873.     bsr    pr_string
  8874.     move.l    (sp)+,a0
  8875.     move.l    a2,d2
  8876.     add.l    d4,d2
  8877.     move.l    a0,d3
  8878.     sub.l    d2,d3
  8879.     beq.s    .E
  8880.     move.l    outhandle(a5),d1
  8881.     jsr    _LVOWrite(a6)    write part after searchstr.
  8882. .E    bsr    pr_lf
  8883.     addq.l    #1,a2
  8884.     bsr    check_c
  8885.     beq.s    .A
  8886. .B    move.l    d5,d0
  8887.     move.l    a3,a1
  8888.     bsr    givemem        free file
  8889. endse    moveq    #RETURN_OK,d0
  8890.     rts
  8891.  
  8892. * Searches for a string
  8893. * ENTRY:a1 points to the string to search for (ends in NULL)
  8894. *     a2 points to start position, a0 to end of file, a3 to start
  8895. * EXIT: a2  to found-position, a0 to NULL- or LF-end, a1 to LF-start
  8896. *    d0=1 not found, d0= found NULL-ended, d0=10 found LF-ended
  8897. searchSTR
  8898.     movem.l    d1-d7/a3-a5,-(sp)
  8899.     moveq    #"Z",d5
  8900.     moveq    #"A",d6
  8901.     moveq    #" ",d7
  8902.     move.l    a1,a4
  8903.     moveq    #0,d4
  8904. .B    move.b    (a4)+,d0
  8905.     beq.s    .D
  8906.     addq.l    #1,d4        count chars to search for
  8907.     cmp.b    d5,d0
  8908.     bhi.s    .A
  8909.     cmp.b    d6,d0
  8910.     blo.s    .A
  8911.     add.b    d7,d0
  8912.     move.b    d0,-1(a4)    lowercase them
  8913. .A    bra.s    .B
  8914. .D    move.b    (a1),d0
  8915.     cmp.b    ctrl_codes+15(a5),d0
  8916.     bne.s    .C
  8917.     move.b    #LF,(a1)    begins with LineFeed
  8918. .C    move.l    a3,a5
  8919.     move.l    a0,d0        calc length of text
  8920.     sub.l    a2,d0
  8921.     sub.l    d4,d0
  8922.     move.l    d0,d4
  8923.     move.l    d4,d3
  8924.     swap    d3
  8925.     moveq    #0,d0
  8926.     moveq    #0,d2
  8927.     move.b    (a1),d2
  8928.     bra.s    seabeg
  8929. seastrt    move.b    (a2)+,d1
  8930.     cmp.b    d5,d1
  8931.     bhi.s    .E
  8932.     cmp.b    d6,d1
  8933.     blo.s    .E
  8934.     add.b    d7,d1
  8935. .E    cmp.b    d2,d1        compare first char
  8936.     bne.s    seabeg
  8937.  
  8938.     lea    1(a1),a3
  8939.     move.l    a2,a4
  8940. .B    move.b    (a3)+,d0
  8941.     beq.s    seafnd
  8942.     move.b    (a4)+,d1
  8943.     cmp.b    d5,d1
  8944.     bhi.s    .F
  8945.     cmp.b    d6,d1
  8946.     blo.s    .F
  8947.     add.b    d7,d1
  8948. .F    cmp.b    d0,d1        compare other chars
  8949.     beq.s    .B
  8950.  
  8951. seabeg    dbra    d4,seastrt
  8952.     dbra    d3,seastrt
  8953.     bra    seaend
  8954.  
  8955. seafnd    subq.l    #1,a2
  8956.     move.l    a2,a1
  8957. .D    cmp.l    a0,a4
  8958.     bhi    seaend
  8959.     move.b    (a4)+,d1    search end
  8960.     beq.s    .G
  8961.     cmp.b    #LF,d1
  8962.     bne.s    .D
  8963.     cmp.b    #LF,(a1)
  8964.     beq.s    .H
  8965. .F    cmp.l    a5,a1
  8966.     bls    .G
  8967.     move.b    -(a1),d0
  8968.     beq.s    .H
  8969.     cmp.b    #LF,d0        search beginning (if LF)
  8970.     bne.s    .F
  8971. .H    addq.l    #1,a1
  8972. .G    move.b    d1,d2
  8973.     lea    -1(a4),a0
  8974.     move.l    d2,d0
  8975.     movem.l    (sp)+,d1-d7/a3-a5
  8976.     rts
  8977. seaend    moveq    #1,d0
  8978.     movem.l    (sp)+,d1-d7/a3-a5
  8979.     rts
  8980.  
  8981. *****************
  8982. *    FAULT    *
  8983. *****************
  8984. faultz    move.l    parm2(a5),d0            V2.0
  8985.     beq    too_less_args
  8986.     move.l    d0,a1
  8987.     bsr    convert_ASCII_to_num
  8988.     beq    bad_number_error
  8989.     bsr    pr_DOSerr
  8990. .A    moveq    #RETURN_OK,d0
  8991.     rts
  8992.  
  8993. *************************
  8994. *    SETCLOCK    *
  8995. *************************
  8996. setclockz lea    $dc0000,a4    ;clockbase    V2.0
  8997.     move.b    1(a4),d4
  8998.     moveq    #75,d1
  8999.     jsr    _LVODelay(a6)
  9000.     cmp.b    1(a4),d4    ;secs changed ?
  9001.     beq.s    noclk
  9002.     lea    clk_tx(pc),a2
  9003.     move.l    parm2(a5),d0
  9004.     beq.s    .A
  9005.     move.l    d0,a0
  9006.     move.l    a2,a1
  9007.     bsr    CheckOpt
  9008.     beq    clkload
  9009.     lea    8(a2),a1
  9010.     bsr    CheckOpt
  9011.     beq.s    clksave
  9012. .A    move.l    a2,a1
  9013.     bsr    pr_stringlf
  9014. uu    moveq    #RETURN_ERROR,d0
  9015.     rts
  9016. noclk    lea    noclk_tx(pc),a1
  9017.     bsr    pr_stringlf
  9018.     bra.s    uu
  9019.  
  9020. clksave    lea    date_mark(a5),a2
  9021.     move.l    a2,a0
  9022.     bsr    get_time
  9023.     move.l    a2,a1
  9024.     lea    -14(sp),sp
  9025.     lea    (sp),a0
  9026.     bsr    convert_time
  9027.     move.b    61(a4),d0    ;reset clock
  9028.     or.b    #1,d0        ;(don't use bset or bclr !)
  9029.     move.b    d0,61(a4)
  9030.     move.b    #0,57(a4)
  9031.     move.b    #5,61(a4)
  9032.     move.b    #4,61(a4)
  9033.     move.b    53(a4),d0    ;hold clock
  9034.     or.b    #1,d0
  9035.     move.b    d0,53(a4)
  9036. clks    btst    #1,53(a4)
  9037.     bne.s    clks
  9038.     lea    (sp),a0
  9039.     lea    chaotab(pc),a1
  9040.     moveq    #1,d6
  9041.     moveq    #0,d1
  9042.     moveq    #5,d0
  9043. .A    move.b    (a1)+,d1
  9044.     moveq    #0,d2
  9045.     move.w    0(a0,d1),d2
  9046.     divu    #LF,d2
  9047.     swap    d2
  9048.     move.b    d2,0(a4,d6)
  9049.     swap    d2
  9050.     move.b    d2,4(a4,d6)
  9051.     addq.l    #8,d6
  9052.     dbra    d0,.A
  9053.     move.b    53(a4),d0
  9054.     and.b    #$0e,d0
  9055.     move.b    d0,53(a4)    ;run clock
  9056.     lea    14(sp),sp
  9057.     moveq    #RETURN_OK,d0
  9058.     rts
  9059.  
  9060. chaotab    dc.b    10,8,6,0,2,4
  9061.  
  9062. getclk    move.b    0(a4,d6),d1    ;Read realtimeclock
  9063.     move.b    4(a4,d6),d0    ;(adress in a4,offset in d6)
  9064.     addq.l    #8,d6
  9065.     and.w    #$f,d0
  9066.     and.w    #$f,d1
  9067.     mulu    #LF,d0
  9068.     add.w    d1,d0
  9069.     ext.l    d0    ;result
  9070.     rts
  9071.  
  9072.         ;load current time from realtime-clock
  9073. clkload    move.b    53(a4),d0
  9074.     or.b    #1,d0
  9075.     move.b    d0,53(a4)
  9076. clkw    btst    #1,53(a4)
  9077.     bne.s    clkw
  9078.     lea    -6(sp),sp
  9079.     lea    (sp),a3
  9080.     moveq    #5,d2
  9081.     moveq    #1,d6
  9082. .A    bsr    getclk
  9083.     move.b    d0,(a3)+
  9084.     dbra    d2,.A
  9085.     lea    (sp),a3
  9086.     bsr    calcsec        ;how many secs ?
  9087.     move.b    53(a4),d0
  9088.     and.b    #$0e,d0
  9089.     move.b    d0,53(a4)
  9090.     lea    6(sp),sp
  9091.     bsr    tset        ;give it to system
  9092.     moveq    #RETURN_OK,d0
  9093.     rts
  9094.  
  9095. calcsec    moveq    #0,d7        ;a3->points to 6 bytes of date/time
  9096.     moveq    #1,d6                    V2.0
  9097.     move.b    (a3)+,d7    ;sec (collect secs in d7)
  9098.     moveq    #0,d0
  9099.     move.b    (a3)+,d0    ;min
  9100.     mulu    #smin,d0
  9101.     add.l    d0,d7
  9102.     moveq    #0,d0
  9103.     move.b    (a3)+,d0    ;std
  9104.     mulu    #sst,d0
  9105.     add.l    d0,d7
  9106.     moveq    #0,d0
  9107.     move.b    (a3)+,d0    ;tag
  9108.     subq.l    #1,d0
  9109.     move.l    d0,d5        ;collect days in d5
  9110.     moveq    #0,d2
  9111.     move.b    (a3)+,d2    ;monat
  9112.     lea    montab(pc),a0
  9113.     moveq    #0,d3
  9114.     move.b    (a3)+,d3    ;jahr
  9115.     move.l    d3,d0
  9116.     and.w    #3,d0
  9117.     bne.s    nosj
  9118.     move.b    #29,1(a0)    ;change montab
  9119. nosj    subq.l    #2,d2
  9120.     bmi.s    jan
  9121. madd    moveq    #0,d0
  9122.     move.b    0(a0,d2),d0
  9123.     add.w    d0,d5
  9124.     dbra    d2,madd
  9125. jan    cmp.b    #78,d3
  9126.     beq.s    tset
  9127.     subq.l    #1,d3
  9128.     moveq    #0,d1
  9129. jadd    add.w    #tjahr,d5
  9130.     move.l    d3,d0
  9131.     and.w    #3,d0
  9132.     bne.s    nosj2
  9133.     addq.l    #1,d5
  9134. nosj2    cmp.b    #78,d3
  9135.     dbeq    d3,jadd
  9136.     move.b    #28,1(a0)
  9137.     move.l    #stag,d1
  9138.     move.l    d5,d0
  9139.     bsr    mult_32x32
  9140.     move.l    d7,d6        ;d6=secs, d5=days
  9141.     add.l    d0,d7        ;d7=all seconds since 1.1.78
  9142.     rts
  9143.  
  9144. clrio    lea    io_Message(a5),a1    ;initialisiert IO-Request  V2.0
  9145.     move.l    a1,a0
  9146.     moveq    #$2f,d0
  9147. clst3    clr.b    (a0)+
  9148.     dbra    d0,clst3
  9149.     move.b    #5,io_Message+8(a5)
  9150.     move.l    thistask(a5),a0
  9151.     lea    pr_MsgPort(a0),a0
  9152.     move.l    a0,io_Message+14(a5)
  9153.     move.w    #$30,io_Message+18(a5)
  9154.     rts        ;a1:IO-Request a0:Msg-Port
  9155.  
  9156. tset    move.l    4.w,a6        ;set time with timer-device (secs in d7)
  9157.     bsr    clrio                V2.0
  9158.     move.w    #40,io_Message+18(a5)
  9159.     lea    timdev(pc),a0
  9160.     moveq    #1,d0
  9161.     moveq    #0,d1
  9162.     jsr    _LVOOpenDev(a6)
  9163.     tst.l    d0
  9164.     bne    tmfehl
  9165.     lea    io_Message(a5),a1
  9166.     move.w    #11,io_Command(a5)
  9167.     clr.w    io_Flags(a5)
  9168.     move.l    d7,tv_secs(a5)
  9169.     clr.l    tv_micro(a5)
  9170.     jsr    _LVODoIO(a6)
  9171.     tst.l    d0
  9172. ;    bne.s    tmfehl    ;better leave out
  9173.     lea    io_Message(a5),a1
  9174.     clr.l    io_Command(a5)
  9175.     jsr    _LVOCloseDev(a6)
  9176. tmfehl    move.l    dosbase(a5),a6
  9177.     rts
  9178.  
  9179. smin    equ    60
  9180. sst    equ    60*smin
  9181. stag    equ    24*sst
  9182. tjahr    equ    365
  9183.  
  9184.  
  9185. *************************
  9186. *    SHOW        *
  9187. *************************
  9188. soffs    dc.w    378,336,350,364,322,392,532
  9189.  
  9190. showz    bsr    rawh_off            V2.0
  9191.     move.l    parm2(a5),d0
  9192.     beq    sdft
  9193.     move.l    d0,a0
  9194.     move.b    (a0),d1
  9195.     bset    #5,d1
  9196.     cmp.b    #"t",d1
  9197.     beq    shtask
  9198.     cmp.b    #"v",d1
  9199.     beq    shvec
  9200.     lea    styp(pc),a0
  9201.     moveq    #6,d0    ;7 Lists
  9202. .D    cmp.b    0(a0,d0.w),d1
  9203.     dbeq    d0,.D
  9204.     move.w    d0,d7
  9205.     bmi    sdft
  9206.     lea    show_tx(pc),a1
  9207.     cmp.w    #2,d7
  9208.     bhi.s    .C
  9209.     lea    show2_tx(pc),a1
  9210. .C    bsr    pr_stringlf
  9211.     bsr    do_forbid
  9212.     add.w    d0,d0
  9213.     lea    soffs(pc),a0
  9214.     move.w    0(a0,d0.w),d0
  9215.     move.l    4.w,a4
  9216.     move.l    0(a4,d0.w),a1
  9217. ;    move.l    8(a4,d0.w),a2
  9218.     lea    tempbuf(a5),a3
  9219. .A    tst.l    (a1)
  9220.     beq.s    .B
  9221.     move.l    a1,(a3)+
  9222.     move.l    (a1),a1
  9223.     bra.s    .A
  9224. .B    clr.l    (a3)
  9225.     bsr    do_permit
  9226.     lea    tempbuf(a5),a3
  9227. da    tst.l    (a3)
  9228.     beq    sdf
  9229.     move.l    (a3)+,a2
  9230.     move.l    10(a2),-(sp)
  9231.     lea    shform(pc),a0
  9232.     cmp.w    #2,d7
  9233.     bhi.s    .E
  9234.     lea    shform2(pc),a0
  9235.     move.w    22(a2),-(sp)
  9236.     move.w    20(a2),-(sp)
  9237. .E    move.b    9(a2),d0
  9238.     ext.w    d0
  9239.     move.w    d0,-(sp)
  9240.     move.l    a2,-(sp)
  9241.     lea    (sp),a1
  9242.     bsr    new_print
  9243.     lea    10(sp),sp
  9244.     cmp.w    #2,d7
  9245.     bhi.s    da
  9246.     addq.l    #4,sp
  9247.     bra.s    da
  9248. sdft    lea    shuse_tx(pc),a1
  9249.     bsr    pr_stringlf
  9250.     moveq    #RETURN_BAD,d0
  9251.     rts
  9252. sdf    moveq    #RETURN_OK,d0
  9253.     rts
  9254.  
  9255. shtask    lea    tempbuf(a5),a3    enough for 96 tasks
  9256.     move.l    4.w,a6
  9257.     jsr    _LVOForbid(a6)
  9258.     lea    420(a6),a0
  9259.     move.l    (a0),a1
  9260. .A    tst.l    (a1)
  9261.     beq.s    .B
  9262.     move.l    a1,(a3)+
  9263.     move.l    (a1),a1
  9264.     bra.s    .A
  9265. .B    lea    406(a6),a0
  9266.     move.l    (a0),a1
  9267. .C    tst.l    (a1)
  9268.     beq.s    .D
  9269.     move.l    a1,(a3)+
  9270.     move.l    (a1),a1
  9271.     bra.s    .C
  9272. .D    move.l    276(a6),(a3)+
  9273.     clr.l    (a3)
  9274.     jsr    _LVOPermit(a6)
  9275.     move.l    dosbase(a5),a6
  9276.     lea    shta_tx(pc),a1
  9277.     bsr    pr_stringlf
  9278.     lea    tempbuf(a5),a3
  9279. prsht    move.l    (a3)+,a2
  9280.     move.l    10(a2),-(sp)
  9281.     move.l    #$00540061,d0    Task
  9282.     cmp.b    #13,LN_TYPE(a2)
  9283.     bne.s    .C
  9284.     move.l    #$00500072,d0    Process
  9285. .C    move.l    d0,-(sp)
  9286.     move.l    tc_SigWait(a2),-(sp)
  9287.     moveq    #0,d0
  9288.     move.b    tc_State(a2),d0
  9289.     lea    ttyp(pc),a0
  9290.     bra.s    .A
  9291. .B    tst.b    (a0)+
  9292.     bne.s    .B
  9293. .A    dbra    d0,.B
  9294.     move.l    a0,-(sp)
  9295.     move.b    LN_PRI(a2),d0
  9296.     ext.w    d0
  9297.     move.w    d0,-(sp)
  9298.     move.l    a2,-(sp)
  9299.     lea    (sp),a1
  9300.     lea    shtaform(pc),a0
  9301.     bsr    new_print        Print it
  9302.     lea    22(sp),sp
  9303.  
  9304.     cmp.b    #13,LN_TYPE(a2)
  9305.     bne.s    snocli
  9306.     move.l    pr_CLI(a2),d1
  9307.     beq.s    snocli
  9308.     lsl.l    #2,d1    ;cli-process
  9309.     move.l    d1,a4
  9310.     lea    null(pc),a1
  9311.     move.l    a1,-(sp)
  9312.     move.l    pr_COS(a2),d1
  9313.     cmp.l    cli_StandardOutput(a4),d1
  9314.     beq.s    .J
  9315.     lea    bigger(pc),a0
  9316.     move.l    a0,(sp)
  9317. .J    move.l    a1,-(sp)
  9318.     move.l    pr_CIS(a2),d1
  9319.     cmp.l    cli_StandardInput(a4),d1
  9320.     beq.s    .G
  9321.     lea    smaller(pc),a0
  9322.     move.l    a0,(sp)
  9323. .G    move.l    a1,-(sp)
  9324.     move.l    cli_CommandName(a4),d1
  9325.     beq.s    .H
  9326.     lsl.l    #2,d1
  9327.     move.l    d1,a0
  9328.     lea    temp2buf(a5),a1        BSTR !
  9329.     move.l    a1,(sp)
  9330.     moveq    #0,d1
  9331.     move.b    (a0)+,d1
  9332.     bra.s    .E
  9333. .F    move.b    (a0)+,(a1)+
  9334. .E    dbra    d1,.F
  9335.     clr.b    (a1)
  9336. .H    move.l    pr_TaskNum(a2),-(sp)
  9337.     lea    null(pc),a1
  9338.     move.l    a1,-(sp)
  9339.     tst.l    cli_Background(a4)    background ?
  9340.     beq.s    .I
  9341.     lea    backcli(pc),a1
  9342.     move.l    a1,(sp)
  9343. .I    lea    proform(pc),a0
  9344.     lea    (sp),a1
  9345.     bsr    new_print        Print CLI-Add
  9346.     lea    20(sp),sp
  9347. snocli    bsr    pr_lf
  9348.     tst.l    (a3)
  9349.     bne    prsht    ;at least one task
  9350. shtok    moveq    #RETURN_OK,D0
  9351.     rts
  9352.  
  9353. shvec    move.l    4.w,a0
  9354.     move.l    eb_KickCheckSum(a0),-(sp)
  9355.     move.l    eb_KickMemPtr(a0),-(sp)
  9356.     move.l    eb_KickTagPtr(a0),-(sp)
  9357.     move.l    eb_ColdCapture(a0),-(sp)
  9358.     move.l    eb_CoolCapture(a0),-(sp)
  9359.     move.l    eb_WarmCapture(a0),-(sp)
  9360.     lea    (sp),a1
  9361.     lea    vec_line(pc),a0
  9362.     bsr    new_print
  9363.     moveq    #RETURN_ERROR,d0
  9364.     moveq    #5,d1
  9365.     move.l    sp,a0
  9366. .A    tst.l    (a0)+
  9367.     bne.s    .B
  9368.     dbra    d1,.A
  9369.     moveq    #RETURN_OK,d0
  9370. .B    lea    6*4(sp),sp    get rid of trash
  9371.     rts
  9372.  
  9373.  
  9374. *************************
  9375. *    MemClock    *    V2.0
  9376. *************************
  9377.  
  9378. ckstackSIZE    equ    2000
  9379. cktask    equ    0        ;Task-Struct
  9380. ckport    equ    cktask+92    ;MsgPort
  9381. ckstack    equ    ckport+34    ;Stack
  9382. ckustack equ    ckstack+ckstackSIZE
  9383. ckdos    equ    ckustack    ;DOSBase
  9384. ckint    equ    ckdos+4        ;Intuitionbase
  9385. ckitxt    equ    ckint+4        ;IntuiTextStruct
  9386. ckdate    equ    ckitxt+20    ;DateStamp
  9387. ckrawdo    equ    ckdate+12    ;DataStream
  9388. ckcook    equ    ckrawdo+6+8    ;Formatted String
  9389. ckrast    equ    ckcook+40    ;Rastports of all Windows
  9390. cknum    equ    ckrast+20*4    ;Number of Windows
  9391. ckalarm    equ    cknum+4        ;Alarm-Time
  9392. ckpad    equ    ckalarm+8
  9393. cksize    equ    ckpad+2
  9394.  
  9395. mlnode    equ    0        ;Memory-List
  9396. mlnum    equ    mlnode+14
  9397. mladdr    equ    mlnum+2
  9398. mllen    equ    mladdr+4
  9399. mlsize    equ    mllen+4
  9400.  
  9401. memclkz    move.l    parm2(a5),d0
  9402.     beq    too_less_args
  9403.     move.l    d0,a0
  9404.     move.b    (a0),d0
  9405.     bset    #5,d0
  9406.     cmp.b    #"a",d0    ;alarm
  9407.     beq    clkalm
  9408.     bsr    CheckOnOff
  9409.     beq    clkoff
  9410.  
  9411. clkon    move.b    #1,memclk_flag(a5)    switch it on
  9412.     move.l    4.w,a6
  9413.     lea    clktask(pc),a1
  9414.     jsr    _LVOFindTask(a6)
  9415.     move.l    d0,a4
  9416.     tst.l    d0
  9417.     beq.s    .A    ;not already running
  9418.     bsr    winclk
  9419. .B    moveq    #RETURN_OK,d0
  9420.     rts
  9421. .A    move.l    #cksize,d0
  9422.     move.l    #1+1<<16,d1
  9423.     jsr    _LVOAllocMem(a6)
  9424.     tst.l    d0
  9425.     beq.s    .B
  9426.     move.l    d0,a4
  9427.     move.w    #$0104,cktask+8(a4)    ;type/pri
  9428.     lea    clktask(pc),a0
  9429.     move.l    a0,cktask+10(a4)    ;name
  9430.     lea    ckstack(a4),a0
  9431.     lea    ckustack(a4),a1
  9432.     move.l    a1,cktask+54(a4)    ;SPreg
  9433.     move.l    a0,cktask+58(a4)    ;lowerstack
  9434.     move.l    a1,cktask+62(a4)    ;upperstack
  9435.     move.l    a4,ckport+16(a4)    ;sigtask
  9436.     lea    ckport+20+4(a4),a0
  9437.     move.l    a0,ckport+20(a4)
  9438.     lea    ckport+20(a4),a0
  9439.     move.l    a0,ckport+20+8(a4)
  9440.     move.l    #mlsize,d0
  9441.     move.l    #1+1<<16,d1
  9442.     jsr    _LVOAllocMem(a6)
  9443.     tst.l    d0
  9444.     beq.s    .B
  9445.     move.l    d0,a2
  9446.     moveq    #1,d0
  9447.     move.w    d0,mlnum(a2)
  9448.     move.l    a4,mladdr(a2)
  9449.     move.l    #cksize,mllen(a2)
  9450.     lea    mlnode(a2),a0
  9451.     lea    cktask+78(a4),a1
  9452.     move.l    a0,-4(a1)
  9453.     move.l    a0,4(a1)
  9454.     move.l    a1,(a0)
  9455.     move.l    a1,4(a0)
  9456.     move.l    dosbase(a5),ckdos(a4)
  9457.     move.l    intuibase(a5),ckint(a4)
  9458.     bsr    winclk
  9459.     move.l    4.w,a6
  9460.     move.l    a4,a1
  9461.     lea    clkstart(pc),a2
  9462.     moveq    #0,d0
  9463.     move.l    d0,a3
  9464.     jsr    _LVOAddTask(a6)
  9465.     move.l    dosbase(a5),a6
  9466.     moveq    #RETURN_OK,d0
  9467.     rts
  9468.  
  9469. winclk    bsr    findrast    ;check if rastport already exists,
  9470.     tst.w    d1        ;else move rastport in table
  9471.     bpl.s    .C
  9472.     moveq    #19,d1
  9473. .B    tst.l    (a1)+
  9474.     dbeq    d1,.B
  9475.     bne.s    .C
  9476.     move.l    d0,-4(a1)
  9477. .C    rts
  9478.  
  9479. findrast
  9480.     move.l    dosbase(a5),a6
  9481.     bsr    GetWindowPtr    window-ptr to a0
  9482.     move.l    $32(a0),d0    rastport
  9483.     lea    ckrast(a4),a0
  9484.     move.l    a0,a1
  9485.     moveq    #19,d1
  9486. .A    cmp.l    (a0)+,d0
  9487.     dbeq    d1,.A
  9488.     rts
  9489.  
  9490. clkoff    clr.b    memclk_flag(a5)    switch it off
  9491. clkof2    move.l    a4,-(sp)
  9492.     move.l    4.w,a6
  9493.     lea    clktask(pc),a1
  9494.     jsr    _LVOFindTask(a6)
  9495.     move.l    d0,a4
  9496.     tst.l    d0
  9497.     beq.s    .A
  9498.     bsr    findrast
  9499.     tst.w    d1
  9500.     bmi.s    .A
  9501.     moveq    #0,d0
  9502.     move.l    d0,-4(a0)
  9503. .A    move.l    (sp)+,a4
  9504.     move.l    dosbase(a5),a6
  9505.     moveq    #RETURN_OK,d0
  9506.     rts    
  9507.  
  9508. clkalm    move.l    4.w,a6        ;set alarm-time
  9509.     lea    clktask(pc),a1
  9510.     jsr    _LVOFindTask(a6)
  9511.     move.l    dosbase(a5),a6
  9512.     move.l    d0,a4
  9513.     tst.l    d0
  9514.     beq.s    .A
  9515.     tst.l    parm3(a5)
  9516.     bne.s    .B
  9517.     lea    ckalarm(a4),a1
  9518.     bsr    pr_stringlf    show alarm
  9519.     bra.s    .A
  9520. .B    move.l    parm3(a5),a0
  9521.     lea    ckalarm(a4),a1
  9522.     moveq    #7,d0
  9523. .C    move.b    (a0)+,(a1)+    set alarm
  9524.     dbra    d0,.C
  9525. .A    moveq    #RETURN_OK,d0
  9526.     rts    
  9527.  
  9528. clkstart sub.l    a1,a1    ;Here starts the MemClockTaskCode !
  9529.     move.l    4.w,a6
  9530.     jsr    _LVOFindTask(a6)
  9531.     move.l    d0,a5
  9532.     move.l    #$00010100,ckitxt(a5)
  9533. .A    move.l    d5,cknum(a5)    ;teststuff
  9534.     lea    ckdate(a5),a0
  9535.     move.l    a0,d1
  9536.     move.l    ckdos(a5),a6
  9537.     jsr    _LVODateStamp(a6)
  9538.     move.l    ckdate+4(a5),d0        ;mins
  9539.     divu    #60,d0
  9540.     move.w    d0,ckrawdo+8(a5)
  9541.     swap    d0
  9542.     move.w    d0,ckrawdo+10(a5)
  9543.     move.l    ckdate+8(a5),d0        ;secs
  9544.     divu    #50,d0
  9545.     move.w    d0,ckrawdo+12(a5)
  9546.     moveq    #2,d1
  9547.     move.l    4.w,a6
  9548.     jsr    _LVOAvailMem(a6)    ;memory
  9549.     move.l    d0,ckrawdo+4(a5)
  9550.     moveq    #1,d1
  9551.     jsr    _LVOAvailMem(a6)
  9552.     move.l    d0,ckrawdo+0(a5)
  9553.     lea    clkform(pc),a0
  9554.     lea    ckrawdo(a5),a1
  9555.     lea    KPutChar(pc),a2
  9556.     lea    ckcook(a5),a3
  9557.     jsr    _LVORawDoFmt(a6)    ;rawdofmt
  9558.     lea    ckcook+26(a5),a0
  9559.     lea    ckalarm(a5),a1
  9560.     moveq    #7,d0
  9561. .D    move.b    (a0)+,d1
  9562.     cmp.b    (a1)+,d1
  9563.     bne.s    .E
  9564.     dbra    d0,.D
  9565.     move.l    ckint(a5),a6
  9566.     suba.l    a0,a0
  9567.     jsr    _LVODisplayBeep(a6)
  9568. .E    lea    ckcook(a5),a0
  9569.     move.l    a0,ckitxt+12(a5)
  9570.     lea    ckrast(a5),a2
  9571.     moveq    #0,d5
  9572.     moveq    #19,d4
  9573. .B    move.l    (a2)+,a0        ;check all 20 Rastports
  9574.     move.l    a0,d0
  9575.     beq.s    .C
  9576.     addq.l    #1,d5
  9577.     lea    ckitxt(a5),a1
  9578.     moveq    #0,d0
  9579.     moveq    #1,d1
  9580.     move.l    ckint(a5),a6
  9581.     jsr    _LVOPrintIText(a6)
  9582. .C    dbra    d4,.B
  9583.     moveq    #LF,d1
  9584.     move.l    ckdos(a5),a6
  9585.     jsr    _LVODelay(a6)        ;wait 1/5 sec
  9586.     tst.l    d5
  9587.     bne    .A
  9588.     move.l    4.w,a6
  9589.     rts
  9590.  
  9591.  
  9592. *************************
  9593. *    CTRL        *    V2.0
  9594. *************************    set or show ctrl-codes
  9595. ctrlz    move.l    parm2(a5),d0
  9596.     beq.s    .A
  9597.     move.l    d0,a0
  9598.     bsr    return_dash_option
  9599.     cmp.b    #'C',d0        option -COMPLET ?
  9600.     beq.s    ctrlcpl
  9601.     cmp.b    #'R',d0        option -RECOLOR ?
  9602.     beq.s    recolor
  9603.     lea    ctrl_codes(a5),a1
  9604.     moveq    #ctrl_inite-ctrl_init-1,d1
  9605. .B    move.b    (a0)+,d0
  9606.     beq.s    .A
  9607.     and.b    #$3f,d0        set ctrl codes
  9608.     move.b    d0,(a1)+
  9609.     dbra    d1,.B
  9610. .A    lea    ctrl_tx(pc),a1    show ctrl codes
  9611.     bsr    pr_string
  9612.     lea    ctrl_codes(a5),a0
  9613.     lea    tempbuf(a5),a1
  9614.     move.l    a1,a2
  9615.     moveq    #ctrl_inite-ctrl_init-1,d1
  9616. .C    move.b    (a0)+,d0
  9617.     add.b    #$40,d0
  9618.     move.b    d0,(a2)+
  9619.     dbra    d1,.C
  9620.     clr.b    (a2)
  9621.     bsr    pr_stringlf
  9622. ctrlend    moveq    #RETURN_OK,d0
  9623.     rts
  9624.  
  9625. ctrlcpl    lea    ignoreit(a5),a1    set or show exeptions of
  9626.     move.l    parm3(a5),d0    filenamecompletition
  9627.     beq.s    .A
  9628.     move.l    d0,a0
  9629.     moveq    #60-1,d0
  9630. .B    move.b    (a0)+,(a1)+
  9631.     beq.s    ctrlend
  9632.     dbra    d0,.B
  9633.     bra.s    ctrlend
  9634. .A    bsr    pr_stringlf
  9635.     bra.s    ctrlend
  9636.  
  9637. recolor    move.l    parm3(a5),d0
  9638.     beq    too_less_args
  9639.     move.l    d0,a3
  9640.     lea    start(pc),a0
  9641.     lea    recol1(pc),a1
  9642.     lea    recol2(pc),a2
  9643.     moveq    #0,d2
  9644.     moveq    #(recol2-recol1)/2-1,d0
  9645. .A    move.w    (a1)+,d1
  9646.     move.b    (a2)+,d2
  9647.     move.b    0(a3,d2.w),d3
  9648.     move.b    d3,0(a0,d1.w)
  9649.     dbra    d0,.A
  9650.     bra    clsz
  9651.  
  9652. *************************
  9653. *    Locate        *    V2.0
  9654. ************************* Show the Path and Filename of a Lock-Struct
  9655. locatez            ;or lock object or delete lock
  9656.     bsr    fixpam32
  9657.     move.l    a0,a3
  9658.     move.l    a1,a2
  9659.     move.l    a0,a1    ;parm2
  9660.     moveq    #0,d7
  9661.     bsr    return_dash_option
  9662.     cmp.b    #"C",d0
  9663.     bne.s    .F
  9664.     moveq    #-1,d7        delete lock after showing
  9665.     move.l    a2,a1
  9666. .F    bsr    convert_ASCII_to_num
  9667.     bne.s    .D
  9668.     moveq    #ACCESS_READ,d2
  9669.     move.l    a2,a1    ;parm3    create lock
  9670.     bsr    convert_ASCII_to_num
  9671.     beq.s    .E
  9672.     move.l    d0,d2
  9673. .E    move.l    a3,d1    ;parm2
  9674.     jsr    _LVOLock(a6)
  9675.     tst.l    d0
  9676.     beq    .A
  9677. .D    move.l    d0,a2        write out name
  9678.     move.l    d0,d6
  9679.     add.l    a2,a2
  9680.     add.l    a2,a2
  9681.     moveq    #ACCESS_WRITE,d1
  9682.     cmp.l    fl_Access(a2),d1    what kind of lock
  9683.     bne.s    .B
  9684.     lea    lockwrite(pc),a1
  9685.     bra.s    .C
  9686. .B    subq.l    #1,d1
  9687.     cmp.l    fl_Access(a2),d1
  9688.     bne.s    .A
  9689.     lea    lockread(pc),a1
  9690. .C    lea    -16(sp),sp
  9691.     move.l    a1,(sp)
  9692.     move.l    fl_Link(a2),12(sp)
  9693.     move.l    d6,8(sp)
  9694.     move.l    d0,d1
  9695.     jsr    _LVODupLock(a6)
  9696.     lea    tempbuf(a5),a0
  9697.     move.l    a0,4(sp)
  9698.     bsr    eval_full_path    evaluate the full name
  9699.     jsr    _LVOUnLock(a6)
  9700.     move.l    sp,a1
  9701.     lea    locktext(pc),a0
  9702.     bsr    new_print
  9703.     lea    16(sp),sp
  9704.     tst.l    d7
  9705.     beq.s    .G
  9706.     move.l    d6,d1
  9707.     jsr    _LVOUnLock(a6)
  9708.     lea    deleteOK(pc),a1
  9709.     bsr    pr_string
  9710. .G    moveq    #RETURN_OK,d0
  9711.     rts
  9712. .A    lea    lockntx(pc),a1
  9713.     bsr    pr_stringlf
  9714. lkerr    moveq    #RETURN_ERROR,d0
  9715.     rts
  9716.  
  9717. *************************
  9718. *    NewCLI        *    V2.0
  9719. *************************
  9720. newcliz    lea    ZShellName(pc),a0
  9721.     move.l    a0,d1        process-name
  9722.     moveq    #0,d2        priority
  9723.     lea    start-4(pc),a0
  9724.     move.l    a0,d3        
  9725.     lsr.l    #2,d3        seglist
  9726.     move.l    #4000,d4    stacksize
  9727.     jsr    _LVOCreateProc(a6)
  9728.     tst.l    d0
  9729.     beq.s    lkerr
  9730.     move.l    d0,a4        a4:new process
  9731.     moveq    #$24,d0
  9732.     move.l    #MEMF_CLEAR+1,d1    memory for Message
  9733.     bsr    iwantmem
  9734.     beq.s    lkerr
  9735.     move.l    d0,a1        a1,a3:message
  9736.     move.l    a1,a3
  9737.     move.b    #5,LN_TYPE(a1)
  9738.     move.l    thistask(a5),a0
  9739.     lea    pr_MsgPort(a0),a2    a2:msgport of this task
  9740.     move.l    a2,mn_ReplyPort(a1)
  9741.     move.w    #$24,mn_Length(a1)
  9742.     move.l    pr_CurrentDir(a0),sm_ToolWindow(a1)
  9743.     move.l    a5,sm_NumArgs(a1)
  9744.     move.l    a4,a0
  9745.     move.l    4.w,a6
  9746.     jsr    _LVOPutMsg(a6)
  9747. .A    move.l    a2,a0
  9748.     jsr    _LVOWaitPort(a6)
  9749.     move.l    a2,a0
  9750.     jsr    _LVOGetMsg(a6)
  9751.     cmp.l    a3,d0
  9752.     bne    .A
  9753. ;    move.l    dosbase(a5),a6
  9754.     move.l    d0,a1
  9755.     moveq    #$24,d0
  9756.     bsr    givemem
  9757.     moveq    #RETURN_OK,d0
  9758.     rts
  9759.  
  9760. *************************
  9761. *    RUN        *    V2.2
  9762. *************************
  9763. runz    clr.l    parm3(a5)
  9764.     bsr    ConvertSemi
  9765.     move.l    parm2(a5),a0
  9766.     bsr    return_dash_option
  9767.     lea    CLIbuf(a5),a1
  9768.     cmp.b    #'C',d0
  9769.     bne.s    .C
  9770.     lea    runnil(pc),a0    redir in/out to nil
  9771.     move.l    a0,parm3(a5)
  9772.     clr.l    parm4(a5)
  9773.     addq.l    #3,a1
  9774. .C    lea    tempbuf(a5),a0
  9775.     move.l    a0,parm2(a5)
  9776.     move.w    #'-c',(a0)+
  9777. .A    move.b    (a1)+,(a0)+    copy CLIbuf
  9778.     bne.s    .A
  9779.     subq.l    #1,a0
  9780.     lea    runit(pc),a1
  9781. .B    move.b    (a1)+,(a0)+    copy appendix
  9782.     bne.s    .B
  9783.     bra    newcliz
  9784.  
  9785. *************************
  9786. *    TaskPri        *    V2.0
  9787. *************************
  9788. taskpriz bsr    fixpam32
  9789.     move.l    a1,a2
  9790.     move.l    a0,a1
  9791.     tst.b    (a1)
  9792.     beq    too_less_args
  9793.     bsr    convert_ASCII_to_num
  9794.     beq    bad_number_error
  9795.     move.l    d0,d7
  9796.     bsr    findtsk
  9797.     beq.s    tskfail
  9798.     move.l    a0,a1
  9799.     move.b    d7,d0
  9800.     move.l    4.w,a6
  9801.     jsr    _LVOSetTaskPri(a6)
  9802. tskok    move.l    dosbase(a5),a6
  9803.     lea    OK_text(pc),a1
  9804.     bsr    pr_string
  9805.     moveq    #RETURN_OK,d0
  9806.     rts
  9807. tskfail    lea    notasktx(pc),a1
  9808.     bsr    pr_stringlf
  9809. tkfail    moveq    #RETURN_ERROR,d0
  9810.     rts
  9811.  
  9812. * Find Task given in a2 (ptr,string,cli-number,null)
  9813. * RETURN: d0,a0 address (0 if not found)
  9814. findtsk    move.l    a2,a1
  9815.     moveq    #0,d0
  9816.     tst.b    (a1)
  9817.     beq.s    .E
  9818.     bsr    convert_ASCII_to_num
  9819.     beq.s    .C
  9820. .E    cmp.l    #20,d0
  9821.     bhi.s    .A        is address
  9822.     move.l    d0,a1
  9823.     tst.l    d0        0 means own task
  9824.     beq.s    .D
  9825.     lsl.l    #2,d0        is a cli-number
  9826.     move.l    dl_Root(a6),a0
  9827.     move.l    (a0),a0
  9828.     add.l    a0,a0
  9829.     add.l    a0,a0
  9830.     add.l    d0,a0
  9831.     move.l    (a0),d0
  9832.     beq.s    .B
  9833.     sub.l    #pr_MsgPort,d0
  9834.     bra.s    .A
  9835. .C    move.l    a2,a1
  9836. .D    move.l    4.w,a6
  9837.     jsr    _LVOFindTask(a6)    search name
  9838.     move.l    dosbase(a5),a6
  9839. .A    tst.l    d0
  9840.     beq.s    .B
  9841.     move.l    d0,a0
  9842.     cmp.b    #01,LN_TYPE(a0)    is it a TASK-struct ?
  9843.     beq.s    .B
  9844.     cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  9845.     beq.s    .B
  9846.     moveq    #0,d0
  9847. .B    tst.l    d0
  9848.     rts
  9849.  
  9850. *************************
  9851. *    Break        *    V2.0
  9852. *************************
  9853. breakz    bsr    fixpam32
  9854.     move.l    a0,a2
  9855.     move.l    a1,a3
  9856.     tst.b    (a2)
  9857.     beq    too_less_args
  9858.     bsr    findtsk
  9859.     beq.s    tskfail
  9860.     move.l    a3,a1
  9861.     move.l    a0,a2
  9862.     tst.b    (a1)
  9863.     beq.s    .B
  9864.     bsr    convert_ASCII_to_num
  9865.     bne.s    .C
  9866.     move.b    (a3),d1
  9867.     bclr    #5,d1
  9868.     cmp.b    #"C",d1
  9869.     blo    tkfail
  9870.     cmp.b    #"F",d1
  9871.     bhi    tkfail
  9872.     sub.b    #55,d1
  9873.     moveq    #0,d0
  9874.     bset    d1,d0
  9875.     bra.s    .C
  9876. .B    move.l    tc_SigWait(a2),d0
  9877. .C    move.l    a2,a1
  9878.     move.l    4.w,a6
  9879.     jsr    _LVOSignal(a6)    set signals given in mask
  9880.     bra    tskok
  9881.  
  9882. *************************
  9883. *    PutMsg        *    V2.0
  9884. *************************
  9885. putmsgz    move.l    parm2(a5),d7
  9886.     beq    printa5
  9887.     move.l    d7,a1
  9888.     bsr    convert_ASCII_to_num
  9889.     bne.s    .D
  9890.     move.l    d7,a1
  9891.     move.l    4.w,a6
  9892.     jsr    _LVOFindPort(a6)    search name
  9893.     move.l    dosbase(a5),a6
  9894.     tst.l    d0
  9895.     beq.s    .B
  9896.     move.l    d0,a0
  9897.     bra.s    .E
  9898. .D    move.l    d0,a0
  9899.     cmp.l    #20,d0
  9900.     bls.s    .B
  9901.     cmp.b    #04,LN_TYPE(a0)    is it a MSGPORT-struct ?
  9902.     beq.s    .E
  9903. .B    move.l    d7,a2
  9904.     bsr    findtsk        search task
  9905.     bne.s    .C
  9906. .A    lea    noporttx(pc),a1
  9907.     bsr    pr_stringlf
  9908.     moveq    #RETURN_ERROR,d0
  9909.     rts
  9910. .C    cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  9911.     bne.s    .A
  9912.     lea    pr_MsgPort(a0),a0
  9913. .E    bsr    clearArgs
  9914.     move.l    thistask(a5),a2
  9915.     lea    pr_MsgPort(a2),a2
  9916.     move.l    a2,sp_reply(a5)
  9917.     move.b    #5,LN_TYPE+sp_node(a5)
  9918.     lea    parm3(a5),a2
  9919.     lea    sp_link(a5),a3
  9920.     moveq    #mn_Size,d2
  9921. .G    move.l    (a2)+,d3
  9922.     beq.s    .F
  9923.     move.l    d3,a1
  9924.     bsr    convert_ASCII_to_num
  9925.     bne.s    .H
  9926.     move.l    d3,d0
  9927. .H    move.l    d0,(a3)+
  9928.     addq.w    #4,d2
  9929.     bra.s    .G
  9930. .F    move.w    d2,sp_length(a5)
  9931.     move.l    sp_link(a5),a1
  9932.     move.b    (a1),d0
  9933.     cmp.b    ctrl_codes+15(a5),d0
  9934.     bne.s    .I
  9935.     lea    sp_link(a5),a1        for DOSpackets
  9936.     move.l    a1,LN_NAME+sp_node(a5)
  9937.     lea    sp_node(a5),a1
  9938.     move.l    a1,sp_link(a5)
  9939.     move.l    sp_reply(a5),sp_port(a5)
  9940. .I    lea    msendtx(pc),a1
  9941.     bsr    pr_stringlf
  9942.     lea    sp_node(a5),a1        message
  9943.     move.l    4.w,a6
  9944.     jsr    _LVOPutMsg(a6)
  9945.     move.l    dosbase(a5),a6
  9946.     clr.l    parm2(a5)
  9947.     bra.s    getmsg1
  9948.  
  9949. *************************
  9950. *    GetMsg        *    V2.0
  9951. *************************
  9952. getmsgz    moveq    #0,d7
  9953.     moveq    #0,d6
  9954.     move.l    parm2(a5),d2
  9955.     beq.s    getmsg1
  9956.     move.l    d2,a1
  9957.     move.l    4.w,a6
  9958.     jsr    _LVOFindPort(a6)    does it already exist ?
  9959.     tst.l    d0
  9960.     bne.s    getmsg1
  9961.     move.l    thistask(a5),a1
  9962.     lea    pr_MsgPort(a1),a1
  9963.     move.l    d2,LN_NAME(a1)
  9964.     jsr    _LVOAddPort(a6)
  9965.     moveq    #1,d6
  9966. getmsg1    move.l    thistask(a5),a2
  9967.     lea    pr_MsgPort(a2),a2
  9968.     move.l    4.w,a6
  9969.     move.l    a2,a0
  9970.     jsr    _LVOGetMsg(a6)
  9971.     tst.l    d0
  9972.     bne.s    .A
  9973.     moveq    #0,d2
  9974.     move.b    MP_SIGBIT(a2),d1
  9975.     bset    d1,d2
  9976.     bset    #SIGBREAKB_CTRL_C,d2
  9977.     move.l    d2,d1
  9978. ;    moveq    #0,d0
  9979.     jsr    _LVOSetSignal(a6)    clear signals
  9980.     move.l    d2,d0
  9981.     jsr    _LVOWait(a6)    wait for msgport or ctrl-c
  9982.     move.l    a2,a0
  9983.     jsr    _LVOGetMsg(a6)
  9984. .A    move.l    dosbase(a5),a6
  9985.     tst.l    d0
  9986.     beq    msgfail
  9987.     move.l    d0,a2
  9988.     move.w    mn_Length(a2),d2
  9989.     move.w    d2,-(sp)
  9990.     move.l    a2,-(sp)
  9991.     lea    msgtx(pc),a0
  9992.     move.l    sp,a1
  9993.     bsr    new_print
  9994.     addq.l    #6,sp
  9995.     sub.w    #mn_Size,d2
  9996.     lsr.w    #2,d2
  9997.     lea    mn_Size(a2),a3
  9998.     bra.s    .D
  9999. .C    move.l    (a3)+,d0
  10000.     cmp.l    #$dfe000,d0
  10001.     bhs.s    .E
  10002.     cmp.l    #$a00000,d0
  10003.     blo.s    .F
  10004.     cmp.l    #$c00000,d0
  10005.     blo.s    .E
  10006. .F    move.l    d0,a0
  10007.     moveq    #79,d1
  10008. .H    move.b    (a0)+,d3
  10009.     beq.s    .G
  10010.     cmp.b    #" ",d3
  10011.     blo.s    .E
  10012.     cmp.b    #"~",d3
  10013.     bhi.s    .E
  10014.     dbra    d1,.H
  10015.     bra.s    .E
  10016. .G    cmp.w    #76,d1
  10017.     bhs.s    .E
  10018.     bsr    printADR
  10019.     bsr    pr_space
  10020.     move.l    d0,a1
  10021.     bsr    pr_stringlf
  10022.     bra.s    .D
  10023. .E    bsr    printADR
  10024.     bsr    pr_lf
  10025. .D    dbra    d2,.C
  10026.     tst.l    d7
  10027.     bne.s    .B
  10028.     tst.l    d6
  10029.     beq.s    .I
  10030.     move.l    thistask(a5),a1
  10031.     lea    pr_MsgPort(a1),a1
  10032.     move.l    4.w,a6
  10033.     jsr    _LVORemPort(a6)
  10034.     move.l    dosbase(a5),a6
  10035. .I    lea    replytx(pc),a1
  10036.     bsr    pr_string
  10037.     bsr    rask
  10038.     move.l    d0,d2
  10039.     beq.s    .B
  10040.     move.l    4.w,a6
  10041.     move.l    a2,a1
  10042.     jsr    _LVOReplyMsg(a6)
  10043.     move.l    dosbase(a5),a6
  10044.     cmp.b    #RETURN_ERROR,d2
  10045.     beq    getmsg1
  10046. .B    moveq    #RETURN_OK,d0
  10047.     rts
  10048. printa5    move.l    a5,-(sp)
  10049.     move.l    sp,a1
  10050.     lea    pra5tx(pc),a0
  10051.     bsr    new_print
  10052.     addq.l    #4,sp
  10053.     bsr    DisplayBeep
  10054. msgfail    moveq    #RETURN_ERROR,d0
  10055.     rts
  10056.  
  10057. *************************
  10058. *    Border        *    V2.0
  10059. *************************
  10060. wd_BorderLeft    equ    54
  10061. wd_Flags    equ    24
  10062.  
  10063. borderz    move.l    parm2(a5),a0
  10064.     bsr    CheckOnOff
  10065.     move.l    d0,-(sp)
  10066.     bsr    GetWindowPtr
  10067.     move.l    a0,a4        this window
  10068.     move.l    intuibase(a5),a6
  10069.     moveq    #0,d0
  10070.     jsr    _LVOLockIBase(a6)
  10071.     move.l    d0,d7
  10072.     move.l    (sp)+,d0
  10073.     beq    bordoff
  10074.  
  10075. bordon    tst.l    bordersize(a5)
  10076.     beq.s    borne
  10077.     bclr    #11,wd_Flags+2(a4)    unset noborder
  10078.     move.l    bordersize(a5),wd_BorderLeft(a4)
  10079.     bra.s    borjo
  10080.  
  10081. bordoff    tst.l    wd_BorderLeft(a4)
  10082.     beq.s    borjo
  10083.     bset    #11,wd_Flags+2(a4)    set noborder-window
  10084.     move.l    wd_BorderLeft(a4),bordersize(a5)
  10085.     clr.l    wd_BorderLeft(a4)
  10086. borjo    moveq    #$00,d0        null resize
  10087.     moveq    #$00,d1
  10088.     move.l    a4,a0
  10089.     jsr    _LVOSizeWindow(a6)
  10090.     move.l    a4,a0
  10091.     jsr    _LVORefreshWindowFrame(a6)    redraw
  10092. borne    move.l    d7,a0
  10093.     jsr    _LVOUnlockIBase(a6)
  10094.     move.l    parm3(a5),d0
  10095.     beq.s    nosiz
  10096.     move.l    d0,a1
  10097.     bsr    convert_ASCII_to_num
  10098.     tst.l    d1
  10099.     beq.s    nosiz
  10100.                 ;resize window to fill screen
  10101.     move.l    $2e(a4),a1    points to screen
  10102.     move.l    d0,d4    width of menubar
  10103.     bpl.s    .A
  10104.     moveq    #0,d4
  10105.     move.b    30(a1),d4
  10106.     add.b    31(a1),d4
  10107. .A    moveq    #-1,d2
  10108.     move.l    12(a1),d3
  10109.     sub.w    10(a4),d3
  10110.     sub.w    d4,d3
  10111.     move.w    d3,d1
  10112.     bpl.s    bklein
  10113.     moveq    #0,d2
  10114.     moveq    #0,d0
  10115.     move.l    a4,a0
  10116.     jsr    _LVOSizeWindow(a6)
  10117. bklein    moveq    #0,d0
  10118.     sub.w    4(a4),d0
  10119.     move.l    d4,d1
  10120.     sub.w    6(a4),d1
  10121.     move.l    a4,a0
  10122.     jsr    _LVOMoveWindow(a6)
  10123.     moveq    #0,d1
  10124.     tst.b    d2
  10125.     beq.s    bgross
  10126.     move.w    d3,d1
  10127. bgross    swap    d3
  10128.     sub.w    8(a4),d3
  10129.     move.w    d3,d0
  10130.     move.l    a4,a0
  10131.     jsr    _LVOSizeWindow(a6)
  10132.     jsr    _LVORethinkDisplay(a6)
  10133.     
  10134. nosiz    move.l    dosbase(a5),a6
  10135.     moveq    #10,d1        wait more than 1/10 sec
  10136.     jsr    _LVODelay(a6)
  10137.     moveq    #RETURN_OK,d0
  10138.     rts
  10139.  
  10140. *************************
  10141. *    Review        *    V2.1
  10142. *************************
  10143. reviewz    move.l    parm2(a5),d0
  10144.     beq.s    ShowReview
  10145.     move.l    d0,a1
  10146.     move.l    d0,a2
  10147.     bsr    convert_ASCII_to_num
  10148.     bne.s    MakeReview
  10149.     or.b    #$20,(a2)
  10150.     cmp.b    #"c",(a2)
  10151.     beq.s    ClearReview
  10152.     cmp.b    #"s",(a2)
  10153.     bne.s    ShowReview
  10154.     move.l    parm3(a5),d0        Save review-buffer
  10155.     beq    too_less_args
  10156.     tst    ReviewSize(a5)
  10157.     beq.s    ShowReview
  10158.     move.l    d0,a3
  10159.     bra    viewbuffer
  10160.  
  10161. ShowReview
  10162.     move.l    ReviewSize(a5),d0    Show review-info
  10163.     bsr    print10
  10164.     lea    view1_tx(pc),a1
  10165.     bsr    pr_string
  10166.     moveq    #RETURN_OK,d0
  10167.     rts
  10168.  
  10169. ClearReview
  10170.     move.l    ReviewMem(a5),a0
  10171.     move.l    ReviewSize(a5),d0
  10172.     move.l    d0,d1
  10173.     swap    d1
  10174.     bra.s    .D
  10175. .E    move.b    #" ",(a0)+    Fill with spaces
  10176. .D    dbra    d0,.E
  10177.     dbra    d1,.E
  10178.     move.b    #LF,-1(a0)    Last char is LF
  10179.     clr.l    ReviewPtr(a5)
  10180.     moveq    #RETURN_OK,d0
  10181.     rts
  10182.  
  10183. MakeReview
  10184.     tst.l    d0            Add review-buffer
  10185.     beq    reviewend
  10186.     tst.l    ReviewSize(a5)
  10187.     beq.s    .F
  10188.     move.l    d0,-(sp)
  10189.     bsr    reviewend
  10190.     move.l    (sp)+,d0
  10191. .F    move.l    d0,d2
  10192.     moveq    #1,d1
  10193.     bsr    iwantmem
  10194.     beq    ShowReview
  10195.     move.l    d0,ReviewMem(a5)
  10196.     move.l    d2,ReviewSize(a5)
  10197.     bsr    ClearReview
  10198.     clr.b    noreview_flag(a5)
  10199.     lea    RHa3(pc),a3        Look for a5-Table
  10200.     tst.l    (a3)
  10201.     bne.s    entryA5
  10202.     moveq    #80,d0
  10203.     move.l    #1+1<<16,d1        "memf_public" & clear it
  10204.     bsr    iwantmem
  10205.     beq    reviewend
  10206.     move.l    d0,(a3)
  10207. APatch    moveq    #_LVOWrite,d2        Add review-patch to DOS Write
  10208.     move.w    #$4ef9,d3
  10209.     move.l    a6,a2
  10210.     add.l    d2,a2
  10211.     moveq    #0,d1
  10212.     cmp.w    (a2),d3
  10213.     bne.s    .B
  10214.     move.l    2(a2),a0
  10215.     lea    RCode(pc),a1
  10216.     cmp.l    a1,a0
  10217.     beq.s    entryA5
  10218.     moveq    #-1,d1
  10219.     bra.s    .C
  10220. .B    cmp.w    #$6000,2(a2)
  10221.     bne.s    reviewend
  10222. .C    movem.l    d0-d1/a0-a1,-(sp)
  10223.     bsr    do_forbid
  10224.     movem.l    (sp)+,d0-d1/a0-a1
  10225.     lea    RHa1(pc),a1
  10226.     move.w    (a2),(a1)
  10227.     move.l    2(a2),2(a1)
  10228.     tst.w    d1
  10229.     bne.s    .D
  10230.     lea    4(a2),a0
  10231.     move.w    (a0),d0
  10232.     ext.l    d0
  10233.     add.l    d0,a0
  10234.     move.l    a0,4(a1)
  10235.     move.w    d3,2(a1)
  10236. .D    lea    RCode(pc),a0
  10237.     move.w    d3,(a2)
  10238.     move.l    a0,2(a2)
  10239.     bsr    do_permit
  10240. entryA5    move.l    (a3),a3            Add a5-table entry
  10241.     moveq    #20-1,d0
  10242. .F    tst.l    (a3)+
  10243.     beq.s    .G
  10244.     dbra    d0,.F
  10245.     bra    reviewend
  10246. .G    move.l    a5,-4(a3)
  10247.     bra    reviewOK
  10248.  
  10249. reviewend        ;Remove review-buffer
  10250.     move.l    RHa3(pc),d0        Remove a5-table entry
  10251.     beq.s    remmem2
  10252.     move.l    d0,a0
  10253.     move.l    a0,a1
  10254.     move.l    a0,a2
  10255.     moveq    #20-1,d0
  10256. .A    cmp.l    (a0)+,a5
  10257.     beq.s    .B
  10258.     dbra    d0,.A
  10259.     bra.s    .D
  10260. .B    clr.l    -4(a0)
  10261. .D    moveq    #20-1,d0    look for other entries
  10262. .C    tst.l    (a2)+
  10263.     bne.s    remmem2
  10264.     dbra    d0,.C
  10265.     bsr    do_forbid
  10266.     lea    RHa3(pc),a0
  10267.     clr.l    (a0)
  10268.     moveq    #80,d0        last entry
  10269.     bsr    givemem
  10270.     moveq    #_LVOWrite,d0        Remove DOS Write Patch
  10271.     move.l    a6,a3
  10272.     add.l    d0,a3
  10273.     move.l    2(a3),a0
  10274.     lea    RCode(pc),a1
  10275.     cmp.l    a0,a1
  10276.     bne.s    remmem
  10277.     lea    RHa1(pc),a1
  10278.     move.w    (a1),(a3)
  10279.     move.l    2(a1),2(a3)
  10280.     cmp.w    #$4ef9,(a1)
  10281.     beq.s    remmem
  10282.     move.w    #$6000,2(a3)
  10283.     lea    4(a3),a2
  10284.     move.l    4(a1),d0
  10285.     sub.l    a2,d0
  10286.     move.w    d0,(a2)
  10287. remmem    bsr    do_permit
  10288. remmem2    move.l    ReviewSize(a5),d0    Remove buffer-memory
  10289.     beq.s    reviewOK
  10290.     move.l    ReviewMem(a5),a1
  10291.     bsr    givemem
  10292.     clr.l    ReviewSize(a5)
  10293. reviewOK
  10294.     moveq    #RETURN_OK,d0
  10295.     rts
  10296.  
  10297. viewbuffer        ;Show the review-buffer using more
  10298.     move.l    ReviewMem(a5),a2
  10299.     move.l    ReviewPtr(a5),d3
  10300.     move.l    ReviewSize(a5),d2
  10301.     bne.s    viewhist
  10302.     rts
  10303. viewhist    ;;Show a circular buffer using more
  10304.     move.l    d2,d4
  10305.     move.l    MPipePtr(a5),d1
  10306.     beq.s    .A
  10307.     move.l    d3,d0    for redirecting to more
  10308.     move.l    d1,d3
  10309.     sub.l    d0,d1
  10310.     bpl.s    .C
  10311.     add.l    d2,d1
  10312.     bra.s    .C
  10313. .A
  10314. .I    move.b    0(a2,d3.l),d0
  10315.     addq.l    #1,d3
  10316.     cmp.l    d3,d2
  10317.     bhi.s    .B
  10318.     clr.l    d3
  10319. .B    addq.l    #1,d1
  10320.     cmp.b    #LF,d0
  10321.     beq.s    .C
  10322.     cmp.b    #12,d0
  10323.     bne.s    .I
  10324. .C    sub.l    d1,d2
  10325.     move.l    d2,d0
  10326.     beq.s    reviewOK
  10327.     moveq    #1,d1
  10328.     bsr    iwantmem
  10329.     beq.s    reviewOK
  10330.     move.l    d0,a0
  10331.     move.l    a0,a1
  10332.     move.l    d4,d1
  10333.     move.l    d2,d4
  10334.     bra.s    .E
  10335. .D    move.b    0(a2,d3.l),d0
  10336.     cmp.b    #12,d0
  10337.     bne.s    .G
  10338.     move.b    #LF,d0
  10339. .G    cmp.b    #"c",d0
  10340.     bne.s    .H
  10341.     cmp.b    #27,-1(a0)
  10342.     bne.s    .H
  10343.     move.b    #" ",-1(a0)
  10344.     move.b    #LF,d0
  10345. .H    move.b    d0,(a0)+
  10346.     addq.l    #1,d3
  10347.     cmp.l    d3,d1
  10348.     bhi.s    .E
  10349.     clr.l    d3
  10350. .E    dbra    d2,.D
  10351.     move.l    a3,d0
  10352.     bne.s    viewwrite
  10353.     move.l    a1,d0
  10354.     move.l    d4,d1
  10355.     moveq    #-1,d2
  10356.     tst.l    MPipePtr(a5)
  10357.     beq.s    .F
  10358.     moveq    #0,d2
  10359. .F    moveq    #0,d4
  10360.     bra    ViewMore
  10361. viewwrite        ;write buffer to file
  10362.     move.l    a1,a2
  10363.     move.l    a3,d1
  10364.     move.l    #MODE_NEWFILE,d2
  10365.     jsr    _LVOOpen(a6)
  10366.     tst.l    d0
  10367.     beq.s    .A
  10368.     move.l    d0,a3
  10369.     move.l    a3,d1
  10370.     move.l    a2,d2
  10371.     move.l    d4,d3
  10372.     move.l    d3,-(sp)
  10373.     jsr    _LVOWrite(a6)
  10374.     move.l    (sp)+,d3
  10375.     sub.l    d0,d3
  10376.     move.l    a3,d1
  10377.     jsr    _LVOClose(a6)
  10378.     moveq    #1,d0
  10379.     tst.l    d3
  10380.     beq.s    .A
  10381.     moveq    #0,d0
  10382. .A    move.l    d0,d2
  10383.     move.l    d4,d0
  10384.     move.l    a2,a1
  10385.     bsr    givemem
  10386.     tst.l    d2
  10387.     beq    DOSerr
  10388.     bra    reviewOK
  10389.  
  10390.     
  10391.  
  10392. *****    ReviewHandler    ********
  10393. RHa1    dc.w    $4ef9    JMP
  10394. RHa2    dcb.w    3    Return-Code
  10395. RHa3    dcb.l    1    Memory-Base-Table
  10396.  
  10397. RCode    movem.l    d0-d3/a5-a6,-(sp)    ;Is called by the DOS Write fkt.
  10398.     move.l    RHa3(pc),d0
  10399.     beq.s    .C
  10400.     move.l    d0,a0
  10401.     moveq    #20-1,d0
  10402. .B    move.l    (a0)+,a5
  10403.     cmp.l    outhandle(a5),d1
  10404.     beq.s    .A
  10405.     dbra    d0,.B
  10406.     bra.s    .C
  10407. .A    tst.b    noreview_flag(a5)
  10408.     bne.s    .C
  10409.     bsr    toreview
  10410. .C    movem.l    (sp)+,d0-d3/a5-a6
  10411.     bra.s    RHa1
  10412.  
  10413. toreview    ;Writes data to review-buffer,Entry: d2=Adress, d3=Length
  10414.     move.l    d2,a0
  10415.     move.l    ReviewMem(a5),a1
  10416.     move.l    ReviewPtr(a5),d1
  10417.     move.l    ReviewSize(a5),d2
  10418.     beq.s    .C
  10419.     bra.s    .B
  10420. .A    move.b    (a0)+,d0
  10421.     move.b    d0,0(a1,d1.l)
  10422.     addq.l    #1,d1
  10423.     cmp.l    d1,d2
  10424.     bhi.s    .B
  10425.     clr.l    d1
  10426. .B    dbra    d3,.A
  10427.     move.l    d1,ReviewPtr(a5)
  10428. .C    rts
  10429.  
  10430.  
  10431. **********************************************************************
  10432. ; check if string in a0 is same as in a1 (limited by null,comma,space)
  10433. ; return: d0=0 for match, 1 otherwise
  10434. CheckOpt
  10435.     move.l    a0,-(sp)
  10436. .A    move.b    (a1)+,d1    compare things
  10437.     beq.s    .B
  10438.     cmp.b    #" ",d1
  10439.     beq.s    .B
  10440.     cmp.b    #",",d1
  10441.     beq.s    .B
  10442.     move.b    (a0)+,d0
  10443.     beq.s    .H
  10444.     cmp.b    ctrl_codes+15(a5),d0    check for .
  10445.     bne.s    .F
  10446.     tst.b    (a0)
  10447.     beq.s    .G
  10448. .F    bsr    compD1D0nocase
  10449.     beq.s    .A
  10450. .H    moveq    #1,d0        failed (not matched)
  10451.     bra.s    .E
  10452. .G    moveq    #0,d0        success    (abbreviated)
  10453. .E    move.b    (a1)+,d1    search for end
  10454.     beq.s    .D
  10455.     cmp.b    #" ",d1
  10456.     beq.s    .D
  10457.     cmp.b    #",",d1
  10458.     bne.s    .E
  10459.     bra.s    .D
  10460. .B    moveq    #1,d0        success or a0 is too long ?
  10461.     tst.b    (a0)
  10462.     bne.s    .D
  10463.     moveq    #0,d0        length is same -> success
  10464. .D    move.l    (sp)+,a0
  10465.     tst.l    d0
  10466.     rts
  10467.  
  10468. *************************
  10469. ; check a0 for ON (d0=1) or OFF (d0=0) option, otherwise error-exit
  10470. CheckOnOff
  10471.     move.l    a2,-(sp)
  10472.     lea    onoffuse(pc),a2
  10473.     move.l    a0,d0
  10474.     beq.s    .B
  10475.     lea    6(a2),a1
  10476.     bsr    CheckOpt
  10477.     beq.s    .A
  10478.     move.l    a2,a1
  10479.     bsr    CheckOpt
  10480.     bne.s    .B
  10481.     moveq    #1,d0
  10482. .A    move.l    (sp)+,a2
  10483.     rts
  10484. .B    move.l    a2,a1
  10485. *************************
  10486. ; print error in a1 and exit
  10487. ErrorExit
  10488.     bsr    pr_stringlf
  10489.     bra    galactic
  10490.  
  10491. *************************
  10492. ; check for Kickstart 2.0 or better, exit on error
  10493. CheckKS    lea    oldkick_tx(pc),a1
  10494.     cmp.w    #36,kickver(a5)
  10495.     blo.s    ErrorExit
  10496.     rts
  10497.  
  10498. **********************************************************************
  10499. ; check if option in a0 is in parm-list and deletes it from parm-list
  10500. ; return: d0=0 for match, 1 otherwise
  10501. LookForOpt
  10502.     movem.l    a2-a3,-(sp)
  10503.     move.l    a0,a2
  10504.     lea    parm2(a5),a3
  10505. .A    move.l    (a3)+,d0    search all parms
  10506.     beq.s    .B
  10507.     move.l    a2,a1
  10508.     move.l    d0,a0
  10509.     bsr    CheckOpt    look for option
  10510.     bne.s    .A
  10511.     lea    -4(a3),a2    found it !
  10512. .D    move.l    (a3)+,(a2)+    delete found parm
  10513.     bne.s    .D
  10514.     moveq    #0,d0
  10515.     bra.s    .C
  10516. .B    moveq    #1,d0        not found !
  10517. .C    movem.l    (sp)+,a2-a3
  10518.     rts
  10519.  
  10520. *************************
  10521. *    MakeLink    *    V2.3
  10522. *************************
  10523. makelinkz
  10524.     bsr    CheckKS
  10525.     moveq    #0,d7
  10526.     moveq    #0,d3
  10527.     lea    linkuse(pc),a2
  10528.     move.l    parm4(a5),d0
  10529.     beq.s    .C
  10530.     move.l    d0,a0
  10531.     move.l    a2,a1
  10532.     bsr    CheckOpt
  10533.     beq.s    .B
  10534.     moveq    #-1,d3
  10535.     lea    8(a2),a1
  10536.     bsr    CheckOpt
  10537.     beq.s    .B
  10538. .C    move.l    a2,a1
  10539.     bra    ErrorExit
  10540. .B    move.l    parm3(a5),d1
  10541.     beq    too_less_args
  10542.     move.l    d1,d2
  10543.     tst.l    d3
  10544.     bne.s    .D
  10545.     moveq    #-2,d2
  10546.     jsr    _LVOLock(a6)
  10547.     move.l    d0,d7
  10548.     beq    DOSerr
  10549.     move.l    d0,d2
  10550. .D    move.l    parm2(a5),d1
  10551.     beq    too_less_args
  10552.     jsr    _LVOMakeLink(a6)
  10553.     tst.l    d0
  10554.     beq    DOSerrUL
  10555.     move.l    d7,d1
  10556.     beq.s    .A
  10557.     jsr    _LVOUnLock(a6)
  10558. .A    moveq    #RETURN_OK,d0
  10559.     rts
  10560.  
  10561. *************************
  10562. *    Flags        *    V2.3
  10563. *************************
  10564. flagsz    lea    parm2(a5),a3
  10565.     move.l    Flags(a5),d3
  10566. .A    move.l    (a3)+,d0
  10567.     beq.s    .F
  10568.     move.l    d0,a0
  10569.     lea    flagsuse+7(pc),a1
  10570.     moveq    #0,d2
  10571. .B    bsr    CheckOpt    look for flag
  10572.     beq.s    .D
  10573.     addq.w    #1,d2
  10574.     cmp.w    #MaxFlags,d2
  10575.     bne.s    .B
  10576.     lea    flagsuse(pc),a1
  10577.     bsr    pr_stringlf
  10578.     bra.s    .C
  10579. .D    move.l    (a3)+,a0    change flag
  10580.     bclr    d2,d3
  10581.     bsr    CheckOnOff
  10582.     beq.s    .A
  10583.     bset    d2,d3
  10584.     bra.s    .A
  10585.  
  10586. .F    moveq    #0,d2        print all flags
  10587.     lea    flagsuse+7(pc),a3
  10588. .E    lea    temp2buf(a5),a2
  10589. .G    move.b    (a3)+,d0
  10590.     move.b    d0,(a2)+
  10591.     beq.s    .H
  10592.     cmp.b    #",",d0
  10593.     bne.s    .G
  10594. .H    subq.l    #1,a2
  10595.     lea    flagsoff(pc),a1
  10596.     btst    d2,d3
  10597.     beq.s    .I
  10598.     lea    flagson(pc),a1
  10599. .I    bsr    addstring
  10600.     lea    temp2buf(a5),a1
  10601.     bsr    pr_string
  10602.     addq.w    #1,d2
  10603.     cmp.w    #MaxFlags,d2
  10604.     bne.s    .E
  10605.     move.l    d3,Flags(a5)
  10606. .C    moveq    #RETURN_OK,d0
  10607.     rts
  10608.  
  10609. *************************
  10610. *    MakeIcon    *    V2.3
  10611. *************************
  10612. makeiconz
  10613.     bsr    CheckKS
  10614.     move.l    parm2(a5),d3
  10615.     beq    too_less_args
  10616.     move.l    parm3(a5),d0
  10617.     beq.s    .E
  10618.     move.l    d0,a0
  10619.     moveq    #1,d2
  10620.     lea    iconuse+7(pc),a1
  10621. .D    bsr    CheckOpt
  10622.     beq.s    .C
  10623.     addq.l    #1,d2
  10624.     cmp.b    #9,d2
  10625.     bne.s    .D
  10626. .B    move.l    dosbase(a5),a6
  10627.     lea    iconuse(pc),a1
  10628.     bsr    pr_stringlf
  10629.     bra.s    .A
  10630. .C    bsr    OpenIconLib
  10631.     beq.s    .B
  10632.     move.l    d2,d0
  10633.     jsr    _LVOGetDefDiskObject(a6)
  10634.     move.l    d0,d2
  10635.     beq    resi_not_found
  10636.     move.l    d0,a1
  10637.     move.l    d3,a0
  10638.     jsr    _LVOPutDiskObject(a6)
  10639.     move.l    d0,d3
  10640.     move.l    d2,a0
  10641.     jsr    _LVOFreeDiskObject(a6)
  10642.     tst.l    d3
  10643.     beq    resi_not_found
  10644. .A    move.l    dosbase(a5),a6
  10645.     moveq    #RETURN_OK,d0
  10646.     rts
  10647.  
  10648. .E    ;shows icon using wb.lib's wbinfo
  10649.     cmp.w    #39,kickver(a5)        needs OS3.0+
  10650.     blo.s    .B
  10651.     bsr    OpenWBLib
  10652.     beq.s    .B
  10653.     move.l    thistask(a5),a0
  10654.     move.l    pr_CurrentDir(a0),a0
  10655.     move.l    parm2(a5),a1
  10656.     move.l    iconbase(a5),a2
  10657.     move.l    $38(a2),a2
  10658.     jsr    _LVOWBInfo(a6)
  10659.     bra.s    .A
  10660.  
  10661.  
  10662. recol1    dc.w    residetx+3-start,assign_tx+4-start,volume_tx+3-start
  10663.     dc.w    device_tx+4-start,breaktx+4-start,locktext+13-start
  10664.     dc.w    show_tx+2-start,show2_tx+2-start,shta_tx+2-start
  10665.     dc.w    proform+4-start,inform_tx+2-start,inform+24-start
  10666.     dc.w    inform2+15-start,stat_text+3-start,totsize+3-start
  10667.     dc.w    dirof+3-start,farb2+3-start,farb3+3-start
  10668.     dc.w    doserrtx+2-start,helpmor+3-start
  10669. recol2    ;Recolour-table to switch globally to one colour
  10670.     dc.b    2,2,2,2,6,3,2,2,2,3,2,7,5,7,7,6,2,3,6,2
  10671.  
  10672.  
  10673. doserror_text
  10674.     dc.b    103,'No free Store',0
  10675.     dc.b    121,'File not Object',0
  10676.     dc.b    202,'Object in use',0
  10677.     dc.b    203,'Object exists',0
  10678.     dc.b    204,'Dir not found',0
  10679.     dc.b    205,'Object not found',0
  10680.     dc.b    209,'Action unknown',0
  10681.     dc.b    210,'Invalid Name',0
  10682.     dc.b    212,'Object wrong Type',0
  10683.     dc.b    213,'Not validated',0
  10684.     dc.b    214,'Disk write-protected',0
  10685.     dc.b    215,'Rename across Devices',0  
  10686.     dc.b    216,'Dir not empty',0
  10687.     dc.b    218,'Device not mounted',0
  10688.     dc.b    221,'Disk full',0
  10689.     dc.b    222,'Delete protected',0
  10690.     dc.b    223,'Write protected',0
  10691.     dc.b    224,'Read protected',0
  10692. nodos    dc.b    225,'Not a DOS Disk',0
  10693. nodisk    dc.b    226,'No Disk present',0
  10694.     dc.b     49,'Not executable',0        305
  10695.     dc.b    0
  10696.  
  10697. ZShellName    dc.b    'ZShell',0
  10698. dosname        dc.b    'dos.library',0
  10699. intuiname    dc.b    'intuition.library',0
  10700. iconname    dc.b    'icon.library',0
  10701. wbname        dc.b    'workbench.library',0
  10702. timdev        dc.b    'timer.device',0
  10703. conname        dc.b    'CON:0/10/640/190/ZShell V2.4/CLOSE',0
  10704. connil        dc.b    'NIL:',0
  10705. wintool        dc.b    'WINDOW',0
  10706. scripttool    dc.b    'SCRIPT',0
  10707. norawtool    dc.b    'NORAW',0
  10708. commandtool    dc.b    'COMMAND',0
  10709. iconifytool    dc.b    'ICONIFY',0
  10710. xpostool    dc.b    'XPOS',0
  10711. ypostool    dc.b    'YPOS',0
  10712. nametool    dc.b    'ICONNAME',0
  10713. welcome        dc.b    "Welcome to ZShell Process %ld !",10,0
  10714. useit        dc.b    "Usage: ZShell [-R] [-Wwindow] [-Sscript]"
  10715.         dc.b    " [-Ccommand] [-N] [-D]",0
  10716. onoffuse    dc.b    "ON or OFF ?",0
  10717. flagsuse    dc.b    "Flags: CHECK,MATCH,ICON,WILD,ERRORS"
  10718.         dc.b    ",DEBUG,CUT,ALL,HIDE",0
  10719. iconuse        dc.b    "Types: DISK,DRAWER,TOOL,PROJECT,GARBAGE"
  10720.         dc.b    ",DEVICE,KICK,APPICON",0
  10721. linkuse        dc.b    "HARD or SOFT ?",0
  10722. assignuse    dc.b    "REMOVE,ADD,PATH,DEFER ?",0
  10723. devicetx    dc.b    "DEVICE",0
  10724. forcetx        dc.b    "FORCE",0
  10725. alltx        dc.b    "ALL",0
  10726. runit        dc.b    ';ask Press RETURN;endcli',0
  10727. runnil        dc.b    '-w',0
  10728. less_args_tx    dc.b    'Not enough arguments',0
  10729. bad_number_tx    dc.b    'Bad number',0
  10730. oldkick_tx    dc.b    'Needs Kickstart 2.0+',0
  10731. clktask        dc.b    'MemClock',0
  10732. clkform        dc.b    ' Mem:%7ld Chip:%6ld  %02d:%02d:%02d ',0
  10733. goto_error_tx    dc.b    'GOTO statement error',10,0
  10734. if_error_tx    dc.b    'IF statement error',10,0
  10735. warn_tx        dc.b    'warn',0
  10736. error_tx    dc.b    'error',0
  10737. fail_tx        dc.b    'fail',0
  10738. not_tx        dc.b    'not',0
  10739. exists_tx    dc.b    'exists',0
  10740. view1_tx    dc.b    ' Bytes',10,0
  10741. badprotbit    dc.b    'Unknown protection bit',0
  10742. residetx    dc.b    27,'[32mUsecount  Adress Name',27,'[m',0
  10743. rpn_result_tx    dc.b    'RESULT: Dec %ld  Hex $%08lx',10,0
  10744. rpn_res2    dc.b    '%ld',0
  10745. failat_tx    dc.b    'Failat: %ld',10,0
  10746. defscript    dc.b    'S:ZStart',0    ;changed V2.0
  10747. rexxtx        dc.b    'REXX:RX',0
  10748. unmounted_tx    dc.b    '[UnMounted]',10,0
  10749. mounted_tx    dc.b    '[Mounted]',0
  10750. assign_tx    dc.b    10,27,'[32mAssigns:',27,'[m',10,0
  10751. volume_tx    dc.b    27,'[32mVolumes:',27,'[m',10,0
  10752. device_tx    dc.b    10,27,'[32mDevices:',27,'[m',10,0
  10753. bad_unset_tx    dc.b    ' could not be unset!',10,0
  10754. breaktx        dc.b    10,27,'[36m*** BREAK ***',27,'[m',10,0
  10755. prompt_args_tx    dc.b    4,'%s> ',0
  10756. stk_too_small_tx    dc.b    'Too Small',10,0
  10757. stk_size_tx    dc.b    'Stack: %ld bytes',10,0
  10758. stack_tx    dc.b    'Stack overflow',0
  10759. lockntx        dc.b    'Give LOCK-BPTR or NAME',0
  10760. lockread    dc.b    'READ',0
  10761. lockwrite    dc.b    'WRITE',0
  10762. locktext    dc.b    '%s-Lock on ',$9b,'33m%s',$9b,'m'
  10763.         dc.b    10,'This Lock: $%06lx  Next: $%06lx',10,0
  10764. clk_tx        dc.b    'LOAD or SAVE ?',0
  10765. noclk_tx    dc.b    'No Clock found',0
  10766. muell_tx    dc.b    'Format: DD.MM.YY or MM-DD-YY or HH:MM:SS',0
  10767. styp        dc.b    'lrdimps'
  10768. shuse_tx    dc.b    'Use D,I,L,M,P,R,S,T or V',0
  10769. show_tx        dc.b    $9b,'32mAdress Pri Name',$9b,'m',0
  10770. show2_tx    dc.b    $9b,'32mAdress Pri Ver Rev Name',$9b,'m',0
  10771. shform        dc.b    '%06lx%4d %s',10,0
  10772. shform2        dc.b    '%06lx%4d%4d%4d %s',10,0
  10773. shta_tx        dc.b    $9b,'32mAdress Pri State SignWait PT '
  10774.         dc.b    'Name',$9b,'m',0
  10775. shtaform    dc.b    '%06lx%4d %-5s %08lx %c%c %s',0
  10776. proform        dc.b    32,9,$9b,'33m->%sCLI %ld:',$9b,'m %s %s%s',0
  10777. backcli        dc.b    "Bg-",0
  10778. ttyp        dc.b    "Inval",0,"Added",0,"Run",0,"Ready",0
  10779.         dc.b    "Wait",0,"Exept",0,"Remov",0
  10780. inform_tx    dc.b    $9b,'32mName Unit Sys    Size    Free Full Block'
  10781.         dc.b    '   Status   Err  Volume',$9b,'m',0
  10782. inform        dc.b    '%-7s%2ld %3s%7ldK%7ldK',$9b,'37m%4ld%%',$9b
  10783.         dc.b    'm%6ld %-10s%3ld   %s',10,0
  10784. inform2        dc.b    '%-7s%2ld     ',$9b,'35m%s',$9b,'m',10,0
  10785. statro        dc.b    "Read only",0
  10786. statrw        dc.b    "Read/Write",0
  10787. statval        dc.b    "Validating",0
  10788. statun        dc.b    "Unknown",0
  10789. baddisk        dc.b    "Unreadable Disk",0
  10790. kickdisk    dc.b    "Kickstart",0
  10791. inhidisk    dc.b    "Not Validated",0
  10792. ofs_tx        dc.b    "OFS",0    OldFilesystem
  10793.         dc.b    "FFS",0    FastFilesystem
  10794.         dc.b    "OIN",0    International OFS
  10795.         dc.b    "FIN",0    International FFS
  10796.         dc.b    "ODC",0    Dir Cache OFS
  10797.         dc.b    "FDC",0 Dir Cache FFS
  10798. msd_tx        dc.b    "MSD",0    MessyDOS
  10799. quest_tx    dc.b    "???",0    Unknown
  10800. OK_text        dc.b    "OK.",10,0
  10801. notasktx    dc.b    "Task not found",0
  10802. noporttx    dc.b    "Port not found",0
  10803. msendtx        dc.b    "send",0
  10804. pra5tx        dc.b    "A5=%06lx",10,0
  10805. msgtx        dc.b    "Message=%06lx  Length=%d",10,0
  10806. time_text    dc.b    "Date: %02d.%02d.%02d    "
  10807.         dc.b    "Time: %02d:%02d:%02d.%02d",10,0
  10808. stat_text    dc.b    27,"[37mResult2=%ld  Time=%02d:%02d:%02d.%02d"
  10809.         dc.b    "  Changes-> Chip:%ld  Fast:%ld  Total:%ld"
  10810.         dc.b    27,"[m",10,0
  10811. lockleft    dc.b    "Locks: %ld -> %ld",10,0
  10812. lowmemtx    dc.b    "Changed %06lx: %08lx -> %08lx",10,0
  10813. failertx    dc.b    27,"[1mFail-Level: %ld",27,"[m",10,0
  10814. replytx        dc.b    "Reply? ",0
  10815. mem_line    dc.b    "%08lx: %08lx %08lx %08lx %08lx   '%s'",10,0
  10816. vec_line    dc.b    "WarmCapture  $%06lx",10,"CoolCapture  $%06lx",10
  10817.         dc.b    "ColdCapture  $%06lx",10,"KickTagPtr   $%06lx",10
  10818.         dc.b    "KickMemPtr   $%06lx",10,"KickCheckSum $%06lx",10,0
  10819. formatask    dc.b    "Delete whole disk ? ",0
  10820. addbufftx    dc.b    "%s has %ld buffers",10,0
  10821. pfeil        dc.b    "-> ",0
  10822. flagsoff    dc.b    ": OFF",10,0
  10823. flagson        dc.b    ": ON",10,0
  10824. appicontx    dc.b    "Shell-It !",0
  10825. Forbidtx    dc.b    "Forbid,Disable!",0
  10826. wbenchtx    dc.b    "Workbench",0
  10827.  
  10828. format        dc.b    '%8ld',0    ;print a longw right justified
  10829. formatADR    dc.b    '$%06lx',0    ;print address 
  10830. totsize        dc.b    27,'[37mTotal Bytes: %ld  Blocks: %ld   '
  10831.         dc.b    'Files: %ld  Dirs: %ld',27,'[m',10,0
  10832. dirtext        dc.b    '(Dir)',27,'[m',0
  10833. cderrtx        dc.b    'Where ?',10,0
  10834. dirof        dc.b    27,'[36mDirectory of -> ',27,'[m',0
  10835. pcurrent    dc.b    "Current Dir",0
  10836. pathc        dc.b    "C:",0
  10837. paths        dc.b    "S:",0
  10838. helpload    dc.b    "Loading ZShell.doc ...",10,0
  10839. msearch        dc.b    12,$9b,'BSearch: ',$9b," p",0
  10840. mjump        dc.b    12,$9b,'BJump to %: ',$9b," p",0
  10841. mwrite        dc.b    12,$9b,'BWrite to: ',$9b," p",0
  10842. prtdev        dc.b    'PRT:',0
  10843. prtit        dc.b    12,$9b,'BPrinting',0
  10844. badcomm        dc.b    'Command not found',10,0
  10845. wrongsize    dc.b    'New size:',0
  10846. makedirOK    dc.b    'created',10,0
  10847. copyOK        dc.b    'copied',10,0
  10848. moveOK        dc.b    'moved',10,0
  10849. joinOK        dc.b    'processed',10,0
  10850. deleteOK    dc.b    'deleted',10,0
  10851. yesnotx        dc.b    'Yes/No/All/Quit ? ',0
  10852. memess        dc.b    "Chip: %ld   Fast: %ld   Total Free: %ld",10,0
  10853.  
  10854. star        dc.b    "*",0
  10855. dot        dc.b    ".",0
  10856. smaller        dc.b    "<",0
  10857. bigger        dc.b    ">",0
  10858. farb1        dc.b    27,'[m',0
  10859. farb2        dc.b    27,'[32m',0
  10860. farb3        dc.b    27,'[33m',0
  10861. lf        dc.b    10,0
  10862. tab        dc.b    9,0
  10863. backspace_it    dc.b    8        DON'T SEPERATE
  10864. delete_it    dc.b    $9b,'P',0        THESE LINES
  10865. return_it    dc.b    13,10,0
  10866. right_cursor    dc.b    $9b,'C',0
  10867. left_cursor    dc.b    $9b,'D',0
  10868. delete_line    dc.b    13,$9b,'M',0
  10869. backslash    dc.b    '/',0
  10870. help_ret    dc.b    'help^M',0
  10871. clstx        dc.b    27,"c",0    reset console
  10872. clrtx        dc.b    12,0    clear screen
  10873. scroll_up_tx    dc.b    $9b,"S",13,0
  10874. scroll_down_tx    dc.b    $9b,"M",$9b,"T",$9b,"1H",0
  10875. clrhide        dc.b    12
  10876. hide_cursor    dc.b    $9b,"0 p",0
  10877. show_cursor    dc.b    $9b," p",0
  10878. askforsize    dc.b    $9b," q",0
  10879. cutontx        dc.b    $9b,"?7l",0
  10880. cutofftx    dc.b    $9b,"?7h",0
  10881. ctrl_tx    dc.b    'Actual CTRL-Codes: ',0
  10882. ctrl_init dc.b    23,17,19,5,9,24,27,20,25,8,10,13,12,18,22,46 CTRL-Codes
  10883. ctrl_inite
  10884. doserrtx    dc.b    $9b,'36mERROR:',$9b,'m'    ;DON'T SEPERATE
  10885. space        dc.b    ' '
  10886. null        dc.b    0        ;THESE 3 LINES
  10887.  
  10888. helpmor    dc.b    13,$9b,"32m %d%% %ld bytes. Use: (shift+)cursor,"
  10889.     dc.b    "(back)space,numeric,s,j,w,r,h",$9b,"K",$9b,"m",0
  10890. helpman    dc.b    "ZShell.Doc",0
  10891. helptx1 dc.b    '$VER: ZShell V2.4 (26.02.95)',10
  10892.     dc.b    "(C)1990,91 Paul Hayter (V1.3); "
  10893.     dc.b    "Updated 1993-95 by Martin Gierich.",10
  10894.     dc.b    "Freeware, NO commercial usage !",10
  10895.     dc.b    "Please send your comments to"
  10896.     dc.b    " uj3w@rz.uni-karlsruhe.de",10,10
  10897.     dc.b    "Commands:",0
  10898. helptx2 dc.b    10,"Options:",10
  10899.     dc.b    "-r/-RECURSIVE: copy,ctrl,delete,dir,join,list,move,protect,",10
  10900.     dc.b    "-c/-CLEAR: avail,ctrl,endcli,locate,path,resident,run",10
  10901.     dc.b    "-q/-QUICK: dir,join,list,delete",10
  10902.     dc.b    "-s/-SORT: copy,move,protect",10
  10903.     dc.b    10,"Wildcards: * ? ~ [] |",10
  10904.     dc.b    "Editing: (SHIFT+) Cursor, <-, DEL,"
  10905.     dc.b    " (SHIFT+) TAB, ESC and see ctrl",10
  10906.     dc.b    ". for dir back, force disk or abbreviation",10
  10907.     dc.b    "Type 'help ?' for more help.",0
  10908. helptx3
  10909.  
  10910. *********************************************
  10911.  
  10912. comtext    dc.b    'addbuffers',0    V1.27
  10913.     dc.b    'alias',0
  10914.     dc.b    'ask',0        V1.28
  10915.     dc.b    'assign',0
  10916.     dc.b    'avail',0
  10917.     dc.b    'border',0    V2.0
  10918.     dc.b    'break',0    V2.0
  10919.     dc.b    'cd',0
  10920.     dc.b    'cls',0        V2.0
  10921.     dc.b    'copy',0
  10922.     dc.b    'ctrl',0    V2.0
  10923.     dc.b    'date',0
  10924.     dc.b    'diskchange',0    V2.0
  10925.     dc.b    'delete',0
  10926.     dc.b    'die',0        V2.0
  10927.     dc.b    'dir',0
  10928.     dc.b    'echo',0
  10929. else_tx    dc.b    'else',0    V1.28
  10930.     dc.b    'endcli',0
  10931. endif_tx dc.b    'endif',0    V1.28
  10932.     dc.b    'eval',0
  10933.     dc.b    'execute',0
  10934.     dc.b    'failat',0
  10935.     dc.b    'fault',0    V2.0
  10936.     dc.b    'filenote',0    V2.0
  10937.     dc.b    'flags',0    V2.3
  10938.     dc.b    'getmsg',0    V2.0
  10939.     dc.b    'help',0
  10940.     dc.b    'htype',0    V1.29
  10941.     dc.b    'if',0        V1.28
  10942.     dc.b    'info',0
  10943.     dc.b    'join',0    V1.29
  10944. label_tx dc.b    'lab',0        V1.29
  10945.     dc.b    'list',0
  10946.     dc.b    'locate',0    V2.0
  10947.     dc.b    'lock',0    V2.0
  10948.     dc.b    'm',0
  10949.     dc.b    'makedir',0
  10950.     dc.b    'makeicon',0    V2.3
  10951.     dc.b    'makelink',0    V2.3
  10952.     dc.b    'memclk',0    V2.0
  10953.     dc.b    'more',0    V1.23
  10954.     dc.b    'move',0    V2.3
  10955.     dc.b    'newcli',0    V2.0
  10956.     dc.b    'path',0
  10957.     dc.b    'prompt',0
  10958.     dc.b    'protect',0
  10959.     dc.b    'putmsg',0    V2.0
  10960.     dc.b    'quit',0    V1.29
  10961.     dc.b    'relabel',0    V1.27
  10962.     dc.b    'rename',0
  10963.     dc.b    'resident',0    V1.25
  10964.     dc.b    'review',0    V2.1
  10965.     dc.b    'run',0        V2.2
  10966.     dc.b    'search',0    V2.0
  10967.     dc.b    'setclock',0    V2.0
  10968.     dc.b    'setdate',0    V2.0
  10969.     dc.b    'show',0    V2.0
  10970.     dc.b    'skip',0
  10971.     dc.b    'stack',0
  10972.     dc.b    'strings',0    V1.29
  10973.     dc.b    'taskpri',0    V2.0
  10974.     dc.b    'type',0
  10975.     dc.b    'unalias',0
  10976.     dc.b    'wait',0
  10977.     dc.b    0
  10978.     
  10979.     
  10980.     cnop    0,2
  10981. comoffs
  10982.     dc.w    addbuffersz-start
  10983.     dc.w    set_funcz-start    ;alias
  10984.     dc.w    askz-start
  10985.     dc.w    assignz-start
  10986.     dc.w    availz-start
  10987.     dc.w    borderz-start
  10988.     dc.w    breakz-start
  10989.     dc.w    cdz-start
  10990.     dc.w    clsz-start
  10991.     dc.w    copyz-start
  10992.     dc.w    ctrlz-start
  10993.     dc.w    datez-start
  10994.     dc.w    diskchangez-start
  10995.     dc.w    deletez-start
  10996.     dc.w    diez-start
  10997.     dc.w    dirz-start
  10998.     dc.w    echoz-start
  10999.     dc.w    elsez-start
  11000.     dc.w    endcliz-start
  11001.     dc.w    endifz-start
  11002.     dc.w    evalz-start
  11003.     dc.w    executez-start
  11004.     dc.w    failatz-start
  11005.     dc.w    faultz-start
  11006.     dc.w    filenotez-start
  11007.     dc.w    flagsz-start
  11008.     dc.w    getmsgz-start
  11009.     dc.w    helpz-start
  11010.     dc.w    htypez-start
  11011.     dc.w    ifz-start
  11012.     dc.w    infoz-start
  11013.     dc.w    joinz-start
  11014.     dc.w    labelz-start    ;lab
  11015.     dc.w    listz-start
  11016.     dc.w    locatez-start
  11017.     dc.w    lockz-start
  11018.     dc.w    memexamz-start    ;m
  11019.     dc.w    makedirz-start
  11020.     dc.w    makeiconz-start
  11021.     dc.w    makelinkz-start
  11022.     dc.w    memclkz-start
  11023.     dc.w    morez-start
  11024.     dc.w    movez-start
  11025.     dc.w    newcliz-start
  11026.     dc.w    pathz-start
  11027.     dc.w    promptz-start
  11028.     dc.w    protectz-start
  11029.     dc.w    putmsgz-start
  11030.     dc.w    quitz-start
  11031.     dc.w    relabelz-start
  11032.     dc.w    renamez-start
  11033.     dc.w    residentz-start
  11034.     dc.w    reviewz-start
  11035.     dc.w    runz-start
  11036.     dc.w    searchz-start
  11037.     dc.w    setclockz-start
  11038.     dc.w    setdatez-start
  11039.     dc.w    showz-start
  11040.     dc.w    skipz-start
  11041.     dc.w    stackz-start
  11042.     dc.w    stringsz-start
  11043.     dc.w    taskpriz-start
  11044.     dc.w    typez-start
  11045.     dc.w    unsetz-start    ;unalias
  11046.     dc.w    waitz-start
  11047.  
  11048. manadr    dc.l    0    here are 2 global variables
  11049. mansize    dc.l    0    because the online-help-manual is used globally
  11050.  
  11051.     end    ;***    here it ends    ***
  11052.  
  11053.